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

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

Postby bvolken » Wed Dec 02, 2015 6:09 am

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 2477 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: 1962
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 474 times
Been thanked: 674 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Postby LeighM » Wed Dec 02, 2015 10:40 am

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: 14582
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4606 times
Been thanked: 4242 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Postby Benj » Wed Dec 02, 2015 11:42 am

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

Postby bvolken » Wed Dec 02, 2015 4:23 pm

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: 14582
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4606 times
Been thanked: 4242 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Postby Benj » Wed Dec 02, 2015 4:39 pm

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

Postby bvolken » Wed Dec 02, 2015 10:56 pm

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 73 times
Programmer: PICKIT3
OS: Windows 10 home 64 bit
FlowCode 6.1.2.0 (11.05.2015)

User avatar
LeighM
Matrix Staff
Posts: 1962
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 474 times
Been thanked: 674 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Postby LeighM » Thu Dec 03, 2015 10:21 am

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: 14582
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4606 times
Been thanked: 4242 times
Contact:

Re: Problem sending character to LCD via UART/Serial

Postby Benj » Thu Dec 03, 2015 10:43 am

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.
These users thanked the author Benj for the post:
bvolken (Fri Dec 04, 2015 10:55 pm)
Rating: 5.26%
 

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

Postby bvolken » Fri Dec 04, 2015 7:26 pm

Okay, turns out the problem was indeed the "Extended CPU Enable"
UART1.jpg
UART1.jpg (86.92 KiB) Viewed 2414 times

After switching to "disabled", the code worked as expected.
HelloWorld.jpg
(138.98 KiB) Downloaded 686 times

THANKS FOR THE SUGGESTION! :D
These users thanked the author bvolken for the post:
LeighM (Mon Dec 07, 2015 10:05 am)
Rating: 5.26%
 
Programmer: PICKIT3
OS: Windows 10 home 64 bit
FlowCode 6.1.2.0 (11.05.2015)