Page 1 of 1

SOLVED: Problem sending character to LCD via UART/Serial

Posted: Wed Dec 02, 2015 6:09 am
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.

Re: Problem sending character to LCD via UART/Serial

Posted: Wed Dec 02, 2015 10:40 am
by LeighM
I would suspect an issue with the serial connection and check the accuracy of the baud rate (if you can)

Re: Problem sending character to LCD via UART/Serial

Posted: Wed Dec 02, 2015 11:42 am
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.

Re: Problem sending character to LCD via UART/Serial

Posted: Wed Dec 02, 2015 4:23 pm
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.

Re: Problem sending character to LCD via UART/Serial

Posted: Wed Dec 02, 2015 4:39 pm
by Benj
Can you attach your program so we can see what might be going wrong.

Re: Problem sending character to LCD via UART/Serial

Posted: Wed Dec 02, 2015 10:56 pm
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"?

Re: Problem sending character to LCD via UART/Serial

Posted: Thu Dec 03, 2015 10:21 am
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

Re: Problem sending character to LCD via UART/Serial

Posted: Thu Dec 03, 2015 10:43 am
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.

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

Posted: Fri Dec 04, 2015 7:26 pm
by bvolken
Okay, turns out the problem was indeed the "Extended CPU Enable"
UART1.jpg
UART1.jpg (86.92 KiB) Viewed 5683 times
After switching to "disabled", the code worked as expected.
HelloWorld.jpg
(138.98 KiB) Downloaded 686 times
THANKS FOR THE SUGGESTION! :D