SOLVED: Problem sending character to LCD via UART/Serial

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
bvolken
Posts: 14
Joined: Mon Nov 30, 2015 1:57 am
Location: California, United States
Has thanked: 6 times
Been thanked: 9 times
Contact:

SOLVED: Problem sending character to LCD via UART/Serial

Post by bvolken »

Target: PIC18F4580
Programmer: PICKIT3
OS: Windows 10 home 64 bit
FlowCode 6.1.2.0 (11.05.2015)

Send a 0x41 to the screen and it puts an "A" exactly as expected.
Send a member of the string array, and display prints junk
Tracing variable as passed to the serial send routine, it looks exactly as I would expect.
Attachments
temp.jpg
temp.jpg (64.2 KiB) Viewed 5208 times
Last edited by bvolken on Fri Dec 04, 2015 7:12 pm, edited 1 time in total.
Programmer: PICKIT3
OS: Windows 10 home 64 bit
FlowCode 6.1.2.0 (11.05.2015)

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Post by LeighM »

I would suspect an issue with the serial connection and check the accuracy of the baud rate (if you can)

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: Problem sending character to LCD via UART/Serial

Post by Benj »

The one second flash test is a great way to sanity check your clock speed and settings are right.

http://www.matrixtsl.com/wiki/index.php ... ED_flasher

Once your clock speed and settings are correct the baud rate should also be correct.

bvolken
Posts: 14
Joined: Mon Nov 30, 2015 1:57 am
Location: California, United States
Has thanked: 6 times
Been thanked: 9 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Post by bvolken »

I know the clock and baud are right. I have run lots of tests. The only change is now trying to send a string (array) one byte-at-a-time.
When I pass "0x41" an "A" is displayed (confirming baud is right), but passing StringVar[4] does not work, even though it appears to pass a valid ASCII code to the print macro.
The CAL_UART is expecting a UINT parameter, and I am passing it a BYTE, which works when I pass "0x41", could this be related to the issue. I couldn't find much on variable typecasting.
Programmer: PICKIT3
OS: Windows 10 home 64 bit
FlowCode 6.1.2.0 (11.05.2015)

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: Problem sending character to LCD via UART/Serial

Post by Benj »

Can you attach your program so we can see what might be going wrong.

bvolken
Posts: 14
Joined: Mon Nov 30, 2015 1:57 am
Location: California, United States
Has thanked: 6 times
Been thanked: 9 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Post by bvolken »

Here you go. I can't help but feel it's got something to do with variable typecasting, but since it's only my 3rd day with Flowcode . . . who knows!?!

Should I download and apply "Flowcode 6 - latest components, bug fixes and improvements"?
Attachments
LCD_Serial.fcfx
(18.74 KiB) Downloaded 234 times
Programmer: PICKIT3
OS: Windows 10 home 64 bit
FlowCode 6.1.2.0 (11.05.2015)

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Post by LeighM »

Hi,

Looking at the generated casm file, it looks like the typecasting is OK, despite it being logical to suspect it, and your code is very good for 3 days with Flowcode!

Have you tried?...
LCD_PrintChar('H')
LCD_PrintChar('e')
LCD_PrintChar('l')
LCD_PrintChar('l')
LCD_PrintChar('o')

I'm just fishing for more clues here.

As you say, updating to the latest is always a good idea

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: Problem sending character to LCD via UART/Serial

Post by Benj »

Hello,

In your config settings switch of the extended CPU setting. This is known to cause corruption with arrays. Then your program should hopefully work as expected.

bvolken
Posts: 14
Joined: Mon Nov 30, 2015 1:57 am
Location: California, United States
Has thanked: 6 times
Been thanked: 9 times
Contact:

Re: SOLVED: Problem sending character to LCD via UART/Serial

Post by bvolken »

Okay, turns out the problem was indeed the "Extended CPU Enable"
UART1.jpg
UART1.jpg (86.92 KiB) Viewed 5145 times
After switching to "disabled", the code worked as expected.
HelloWorld.jpg
(138.98 KiB) Downloaded 686 times
THANKS FOR THE SUGGESTION! :D
Programmer: PICKIT3
OS: Windows 10 home 64 bit
FlowCode 6.1.2.0 (11.05.2015)

Post Reply