UART between 2 PIC16LF88's

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

UART between 2 PIC16LF88's

Post by christoph »

Hi Ben,

I used your suggested method (see Flowcode V4.5 flowchart attachments) and they run fine in simulation and config. and download with no problem. However, when I tried the chips hardwired I get no result at the Rx (lighting the appropriate 1 of 6 LED's on Port B dependent on the contact being made on Port A).

The 'other' details are: I am using 3.3 volts supply (the LF version is 2v to 3.5v), Internal oscillator, INTRC as Port I/O, clock speed 19660800 Hz

After programming I kept it simple for the test of one switch and one LED, the ONLY conections I have made therefore are: +ve, -ve, Tx Pin 11 to Rx Pin 8 (UART signal), a 10k pull-down resistor from RA0 (input) with a clean contact across +ve and RA0 for the Transmitter and on the Receiver - an LED from RB0 (output) to -ve via a 1k resitor.

Any ideas would be greatly appreciated - I have run out of things to try now.

Best regards,

Chris :(
Attachments
UART RX(LF88) 6 switch.fcf
(14 KiB) Downloaded 286 times
UART TX(LF88) 6 switch.fcf
(12.5 KiB) Downloaded 288 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: UART between 2 PIC16LF88's

Post by medelec35 »

Hi Chris,
christoph wrote: The 'other' details are: I am using 3.3 volts supply (the LF version is 2v to 3.5v), Internal oscillator, INTRC as Port I/O, clock speed 19660800 Hz
You can't set internal osc to 19660800 Hz.

Without a C code block placed at the beginning of main the internal oscillator will be running at a default frequency which will not be 19660800Hz

Since you have set target osc speed to 19660800Hz since this is only for all the timings for delays e.g for LCD, RS232 etc
then these components will not work.

what you need to do is look in the datasheet at what frequency you would like, then place a C code block at the beginning of Main with correct osccon value to set the oscillator at the correct speed.

From looking at the data sheet 16F88 can only be set to the following internal oscillator frequencies:

Code: Select all

31.25 kHz
125 kHz
250 kHz
500 kHz
1 MHz
2 MHz
4 MHz
8 MHz
Take a look here on how I determine correct value:
http://www.matrixmultimedia.com/mmforum ... 12&#p28829
Finally set the target value to chosen value e.g 4MHz and check UART component is set at correct Baud rate.

Hope this helps

Martin
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

Thanks for the post. Wow! I did have an inkling in the back of my mind that it had to do with timing etc. but I will inwardly digest from your info. and link and see how I get on. I have to say I am 'dreading' the thought of using C, as programming was putting me off using micro-c's in the first place!

Many thanks,

Best regards,

Chris :)

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin and all,

OK I have taken that all on board. In my case (16F88), the osccon register uses 3 bits 6-4 so the binary will be 01100000 which is hex: 0x60 for the '4MHz = 110' shown in the PIC data sheets. However I looked at the link attachments and was assuming that I would pick the C icon and type in 'osccon=0x60' in the properties (as shown on the link flowchart) but it appears to be a bit mor complicated re the instructions that appear when I select the icon on MY flowchart (see my attachments) under 'properties'. Do I, not need to do anything with the other 'bits' ? I also noticed on the link's flowchart, that 'supplementary code' is not ticked - should it be in my case? In 'Project Options', do I just leave the clock speed of 19660800Hz at that value? I have set the Baud rate at 9600 (which is required by the radio system I will be using). What settings should I use for configuring the chip itself apart from 'Internal oscillator' (which I have done) and particularly under 'Configuration Expert' such as 'oscillator selection' etc.?

Sorry but still got my L plates on and very large ones concerning C!.

Would appreciate bit of additional help before I can implement this re my attachments,

Many thanks

Chris

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Benj,

Would you able to enlighten me on the above points if possible?

Chris

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: UART between 2 PIC16LF88's

Post by medelec35 »

Hi Chris,
Clock speed has to be changed to 4MHz in View, Project Options menu
As stated in previous post C block with osccon=0x60; is placed at the start of main.
You need to set oscillator in expert configuration screen to internal which you have done.
All other settings look correct so long you have a pull-up resistor connected between pin 4 and + supply.
If this pin is left floating then chip will not run until RA5/MCLR is changed to RA5

I have altered one of your flowcharts for you with osc set to correct speed and added C block with correct osccon value for 4MHz.

So you should be able to alter your other Flowchart in the same way

Martin
Attachments
UART RX16LF88switch.fcf
(10 KiB) Downloaded 289 times
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

Many, many thanks for your interest and for updating a flowchart as an example. I will start following it all up within the hour. Will let you know how I get on!

Best regards,

Chris :D

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: UART between 2 PIC16LF88's

Post by medelec35 »

No problem.
Hope it all for you.

Martin
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

Well strangley I still can't get any reaction. I could only get the 'complicated' stuff showing, when I picked the flowchart C icon so was bold and deleted all in the properties box stuff and typed in 'osccon=0x60' on line 1 and ignored the fact that '2' was showing for line 2 - but it messaged 'failure' when I tried to configure, so I simply did a 'copy' (of your Rx one) and 'paste' and it all config'd fine and programmed the chip. I used 10k pull-up's on pin 4 of both chips. I have a 10k pull-down resistor on pin 17 (RA0) of the Tx chip to put +ve onto that pin as a switch 'ON' to turn on the Rx LED output from RA0. I have been through everything to check and can't find anything amiss. For RS232 'properties' it does say XTAL 4000000 and 'Error' 0.16% but wouldn't think that a problem? Could it be something to do with the timing still? Bearing in mind, however, I need to use 9600 Baud for the radio system. Is it anything to do with these being 16LF88 low supply voltage chips which I am running at about 3.1volts ( but good for 2volts ). In the earlier posts it appeared that these low voltage supply chips run slower ? Hardware wise there is just the wiring, resistors, 2 chips and the LED on a dedicated two and a half inch square piece of new breadboard so I'm certain the connections are OK! The only other thoughts were that I hopefully, correctly put the C icon between 'BEGIN' and 'loop' icon for the TX and on my VERY old 'scope I get a 3 volt level change on the transmitter output pin 11 but no detail just a horizontal line.

Sorry to be a pain but any idea what I could try?

Best regards,

Chris

UPDATE: 8/2/12 9:45 Disconnecting the RS232 link between the two PIC's to concentrate on the Tx device and connecting the 'scope to the Tx pin 11- I put the power on and was presented with a straight line trace which went from 0v to the 3v and stayed there. Whilst moving the board though I saw an occasional pulse or two which 'died away' quickly. Then I found that whilst connecting and disconnecting power I occasionally got what I can only describe as 8 'blinks' (not 0v to 3v transitions but more like normal intensity of the trace to much less then to normal again on the 3v trace line) at APPROX. 1/4 second intervals and 8 pulses would correspond to the transmitter which currently is programmed for 8 loop bytes only, when power is applied. I notice too, that if I take off power and put it back on quickly that I dont see the blinks - only if I wait 3-4 secs (presumably to let capacitance etc, for oscillator and chip to die away. So I will try putting a start-up delay between 'BEGIN' and 'C' icon also between 'C' icon and start of '8x loop'.

Any comments that might help would still be gratefully received though
Last edited by christoph on Wed Feb 08, 2012 11:14 am, edited 1 time in total.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: UART between 2 PIC16LF88's

Post by medelec35 »

christoph wrote: when I picked the flowchart C icon so was bold and deleted all in the properties box stuff and typed in 'osccon=0x60' on line 1 and ignored the fact that '2' was showing for line 2 - but it messaged 'failure' when I tried to configure,


Hi Chris,
Your flowchart may not of successfully compiled because you have omitted the semicolon after osccon=0x60
It should be osccon=0x60;

I believe you will be struggling with the target device you are using, especially if you use LCD, 8 switches and built in UART component.
Reason is the UART would take over two pins (RB2 and RB5) of microcontroller.
So LCD will not work!
What you could consider is connect is not to use RB2 or RB5 for LCD, but use RB6 and RB7 instead

There will be no reason for TX or RX of uart not to work.
You may only see a flat line because there are only 8 loops and if scope does not have single shot mode then they may be over too quickly.
For testing you could change loop count 8
To loop while 1 which will loop your program for ever.
To help you in the future I believe when designing a Flowchart, first thing to do is:
Loop while 1
Portx = 255
Delay 500ms
Portx = 0
Delay 500ms
Loop for ever

Where x is the port your interested in
This will kill two birds with one stone..

1) Will test what bits of port will work
2) Will test oscillator is correctly configured.
If you want to test with UART, then set flowchart up to send and receive a char, before the port test loop.

Martin
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

I have actually got the semi-colon in the Tx, as I copied and pasted your C icon over when I updated the items. But thanks muchly for your additional comments and I will action accordingly. We might have been posting at much the same time so just wondering if you saw my edited update at the bottom of my posting which you were just answering. That is about putting a delay each side of the C icon for the Tx - and the Rx for that matter. Also, you are right - when I peer closely I can JUST make out the imperceptable drop to 0v between1's and 0's.
I agree with you re LCD etc. but have nothing connected or programmed on the Tx other than 6 switches and only the 6 LED's for the Rx I realised early on that certain port bits were not available for what I was doing like MCLR, input only, Rx/Tx etc. so I am only using the 6 bits that are in/outs on both chips with no complications.

About your comment "...test with UART........", Do you mean effectively that for testing, I could have a TEST FLOWCHART with the Tx flowchart, Rx flowchart and the port test loop to check the whole simulation out?

Chris

Have just done some more work on Tx and loop while 1 + more tweaking on 'scope and I am able to see two dips 'pulses' on scope so I think Tx hardware is OK. The receiver shows no sign of wanting to output anything on any of the 6 pins so I believe this might be something to do with mis-matching my signal selection. For the Tx, I showed all 8 of port A toggling switches (but, as I say, I am only using 6) and depending on their position I get the appropriate 0 or 1 on the LCD (LCD not programmed on chip though). On the Rx I used the RS232 block to input bytes (e.g. 5,79,220) and each received byte binary is displayed on the 8 LED's. Is that workable? I have a nagging feeling it isn't!

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: UART between 2 PIC16LF88's

Post by medelec35 »

Don't forget with RS232 set at 9600 the time duration for each bit is 1/9600 = 104 microseconds. Also not all bits will cause voltage drop to 0 so if scope doesn't display captured waveforms then your not going to see that much of a blip!

Attached is a RS232 RX version that was created sometime ago. I have modified it so the corrisponding LEDs should light for the number that's sent.
E.g you send a 2 and A1 will light etc.
Hope this will help.

Martin
Attachments
RS232 RX.fcf
(8.5 KiB) Downloaded 268 times
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Thanks Martin I will try that right away........

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

Your Rx works perfectly (and similarly to Benj's that he suggested in an e-mail ) on simulation and 'loaded up' fine but nothing out of any receiver pin again I'm afraid. I spent most of the day going thro' all the data sheets and your comments and checking breadboard connections (simple though they are1) and have just tried another new pair of LF88's before testing your flowchart and everything seems as it should be. I made one change earlier 'cos I spotted the reason why I was not getting the actual binary number generated from the switch positions on Tx - it was because I had the wrong variable but changed it to 'out', which is what it should have been and THOUGHT that was the problem solved but unfortunately not. I take your point about the 'scope but with the Tx bsasically showing a straight +3v trace, I do now get a 300 microsecond (approx.) drop to 0v on the 1cm to 1 millisecond range at the output from Tx on pin 11. I have no idea what else Could be tried. I don't really know much about timing but is it actually worth trying less than 4 Meg? I have to use the standard 9600 baud for the radio though as noted before.

I know it is difficult but have you any other ideas I could try or check? What is so frustrating is it is such a simple set up as it stands...

Best regards,

Chris

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: UART between 2 PIC16LF88's

Post by medelec35 »

Hi Chris,
Since I have two EB006 programmers, Before posting any more flowcharts, I decided to connect them both together to perform transmit and received functions.
I can now confirm that My hardware is woking 100%. If I press sw1 connected to RA0 of transmitter, then LED connected to RA0 on the receiver does light up.
If I press two switches e.g RA0 and RA4, then both LEDs connected to RA0 and RA4 also light up etc.

The only LED that will not work is RA5 since that is an input only!

So looks like its solved for you :)

One thing out of curiosity what was the reason for converting to binary first?
Only asking since TX Flowchart could be neatly as simple as RX one with out conversion first.

Not that it really matters :lol:


Martin
Attachments
RS232 RX.fcf
(10 KiB) Downloaded 198 times
UART TX(LF88) 6 switch2.fcf
(12.5 KiB) Downloaded 192 times
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

As it is about 2:15 am in the morning I thought I would pack up for tonight and I realised the internet had 'dropped out' so just checked and saw your post - many thanks and will try the combination in the morning. Yes it really, really should work!!! Even I, as a beginner, can see that and it is really such a simple programme which I understand much better now through your patient efforts to sort this out.

I have no reason to convert to binary for the Tx (it was Matrix's suggestion in the early stages when I was struggling with virtually no knowledge of how to achieve what I was trying to do) BUT I would MUCH prefer to go with simpler solution which you say would be nearly as simple as the Rx, because all I need to do is exactly as you describe: make any contact at Tx and light appropriate LED(s) at Rx via a 9600,N,8,1 SERIAL UART wireless link. Would it be possible to post an attachment .fcf for that?

Best regards,

Chris :)

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: UART between 2 PIC16LF88's

Post by medelec35 »

Hi Chris,
This simplified version also works on my hardware.

One thing though, I have posted some time ago a decimal to hex and hex to decimal converter.
All it does is takes a variable assigned with a number, then displays the hex valur on LCD.

The flowchart you posted that converts switch pressed in to binary would make a great addition to decimal to hex converter!


Martin
Attachments
UART TX(LF88) 6 switch3.fcf
(8.5 KiB) Downloaded 194 times
Martin

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

Many thanks for the .fcf and for spending time checking that it all works as well. I'm pleased the 'switch/binary flowchart' will not wasted and I will have a play with that when I get the current set up working cos I can see it is a potentially useful addition to the 'armoury'! I shall now have another go at getting this project going - fingers crossed!! I will let you know how it goes.

Best regards,

Chris :D

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

No luck I'm afraid. Pretty sure Tx is OK cos I reprogrammed the Tx as the Rx and vica versa and the Tx gave exactly the same trace on the 'scope. In desparation I was going to change to 5 volt PIC's but only have one 5v F88 which I was going to use for the Tx and the only other device I have with UART is an F887A but that doesn't have internal oscillator and I haven't any crystals so I need to do a bit more work and some ordering!
I can only think that the low voltage supply chips are different to the 5 volt ones in some way otherwise I simply cannot see why I get nothing (checked with 'scope and meter) out of any receiver output having tried new devices as well. That is why I wanted to test with non-LF's which your checks have proved - work! Ultimately I need the LF's but I have to get SOMETHING working after all our collective efforts! I am trying again tonight - first with a reduced oscillator speed......!

I remembered I have 3 x PIC16LF1933's and I will try them out as well!

Best regards,

Chris

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Martin,

Thought you (and anyone else who might have been following this selection of posts) would like to know that I received the pair of 'straight' PIC16F88's from RS today and they work PERFECTLY!!! I'm wondering what is different about the PIC16LF88's, because I used the same flowcharts to programme both types! I do have two more new FL88's but I don't want to use them until I know what needs tweaking. I know from what has been discussed previously, that there shouldn't be any difference but something is causing a hitch. I know speed was a consideration for these low power devices but although I thought I would try reducing it to something less than the 4MHz I don't want to change the 9600 baud rate and is it speed anyway as I notice that a PIC16LF88 at 10MHz with UART is being used for SPARKFUNs' Serial enabled LCD?
I HAVE been looking through the Data for this device but for the most part, the F & LF versions are 'lumped' together generally and as I am still in the early learning stages of microchips, there may be something which would indicate what needs to be done, which I might have missed the significence of. I'm a bit 'concerned' because I really need to power these chips from around 2 to 3 volts.

By the way Martin, the Foxit free reader is excellent - thanks for that!

Best regards,

Chris

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: UART between 2 PIC16LF88's

Post by medelec35 »

christoph wrote: By the way Martin, the Foxit free reader is excellent - thanks for that!
Hi Chris,
Glad you like the reader, it does have some good added extras.

As for the two uarts working, then hope changing tx baud rate to a lower value works.
see:
http://www.matrixmultimedia.com/mmforum ... 220#p32332
I'm wondering if SPBRG reg is changed in 16LF88?

Martin
Martin

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: UART between 2 PIC16LF88's

Post by kersing »

Chris,

When you are testing with the 16F88 you are using 5V I guess. Are you using 3V for the 16LF88? If so, would it be possible to test them with 5V to see if it makes any difference?

Regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: UART between 2 PIC16LF88's

Post by Benj »

Hi Chris,

There shouldn't be any real difference between the LF and the F devices.

Just incase it makes any difference here is a FCD for the 16LF88 device.
16LF88.fcd
(10.8 KiB) Downloaded 191 times
You can add it to Flowcode by downloading the file and copying it into your Flowcode v4/FCD folder.

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: UART between 2 PIC16LF88's

Post by christoph »

Hi Ben,

Thanks for that - couldn't follow up yesterday cos major boiler problem but I am about to check it out now but I can't find a v4/FCD folder. Where do I find it?

Edited: I now find that when I try to DOWNLOAD it even, the file type is not recognised and when I try to open ot with Flowcode a message says "access denied"!

Regards,

Chris

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: UART between 2 PIC16LF88's

Post by Benj »

Hi Chris,

The file I send is a Flowcode definition file.
You can add it to Flowcode by downloading the file and copying it into your Flowcode v4/FCD folder.
Once you have copied the file to the folder the 16LF88 will then appear in the Flowcode device list.

Post Reply