Page 1 of 1

PIC18F27K42 - UART

Posted: Fri Oct 18, 2019 10:20 am
by medelec35
Errors with UART component:

Code: Select all

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:408:1: error: (192) undefined identifier "TXSTAbits"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:408:16: error: (196) struct/union required
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:411:1: error: (192) undefined identifier "SPBRG"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:412:1: error: (192) undefined identifier "RCSTA"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:423:1: error: (192) undefined identifier "RCSTAbits"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:423:16: error: (196) struct/union required
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:426:16: error: (196) struct/union required
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:429:16: error: (196) struct/union required
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:437:15: error: (255) not a member of the struct/union ""
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:437:18: error: (182) illegal conversion between types
int -> volatile union S151
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:708:1: error: (192) undefined identifier "RCSTA"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:709:1: error: (192) undefined identifier "TXSTA"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:788:1: error: (192) undefined identifier "TXREG"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:901:26: error: (255) not a member of the struct/union ""
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:901:27: error: (182) illegal conversion between types
volatile union S178 -> unsigned char
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:901:27: error: (181) non-scalar types can't be converted to other types
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:949:13: error: (192) undefined identifier "RCSTAbits"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:949:27: error: (196) struct/union required
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:952:9: error: (192) undefined identifier "RCREG"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:959:27: error: (196) struct/union required
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:962:16: advisory: (1) too many errors (21)
(908) exit status = 1

Error returned from [xc8.exe]

Re: PIC18F27K42

Posted: Mon Oct 21, 2019 1:03 pm
by Benj
Thanks for the spot Martin,

Looks like they totally re-wrote the rulebook for this one. The register setup is nothing like the other chips.

Hmm I'll have a think on it.

Re: PIC18F27K42

Posted: Mon Oct 21, 2019 2:00 pm
by Benj
Hi Martin,

I've had a go at editing the code. Do you have one of the chips to hand?

If you do then please can you try this and let me know how you get on.
PIC_CAL_UART.c
(41.89 KiB) Downloaded 208 times
If all ok then I'll push to the update system.

Thanks.

Re: PIC18F27K42

Posted: Mon Oct 21, 2019 3:30 pm
by medelec35
Hi Ben,
the baud is set to 9600
Measured baud is 38.5K
Internal Osc speed is correct @ 48MHz as UART works in software mode.
Will Test RX after TX confirmed working.

Re: PIC18F27K42

Posted: Mon Oct 21, 2019 3:41 pm
by Benj
Thanks Martin,

What about this?
PIC_CAL_UART.c
(41.89 KiB) Downloaded 206 times

Re: PIC18F27K42

Posted: Mon Oct 21, 2019 3:51 pm
by medelec35
You're welcome.
Baud dropped to 151 bits per sec

Re: PIC18F27K42

Posted: Mon Oct 21, 2019 4:34 pm
by Benj
Aha thanks, yes I see now it's missing the usual FOSC/4 for the clock input :)

I've changed the new baud calc so it's actually using the full 16-bit range with the FOSC clock source.
PIC_CAL_UART.c
(46.15 KiB) Downloaded 210 times
Let me know how you get on.

Re: PIC18F27K42

Posted: Mon Oct 21, 2019 5:48 pm
by medelec35
Hi Ben,
Thank you.
RX and TX are now working perfect.
Tested at 9600 and 38400 BPS

Re: PIC18F27K42 - UART

Posted: Tue Oct 22, 2019 12:36 pm
by Benj
Thanks :D

I've pushed the changes to the update system now.

Re: PIC18F27K42 - UART

Posted: Thu Oct 24, 2019 3:32 pm
by medelec35
Hi Ben,
Something has gone wrong with pushing the update on the system.
The file you posted compiles ok.
When compile with V6.0, The following errors occur:

Code: Select all

M:\Flowcode Testing>"C:\Program Files (x86)\Microchip\xc8\v2.05\bin\xc8-cc.exe" -mcpu=18F27K42 "PIC18f27K42.c" -w=359,1273,1388 -fshort-float -fshort-double -std=c90 -Os 
. . . .

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:471:15: error: (255) not a member of the struct/union ""
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:471:18: error: (182) illegal conversion between types
int -> volatile union S151
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:854:26: error: (255) not a member of the struct/union ""
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c:854:32: error: (207) simple type required for "=="
NOT volatile union S1161
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8 V2.05_comp.bat reported error code 1

Re: PIC18F27K42 - UART

Posted: Fri Oct 25, 2019 9:51 am
by Benj
Thanks Martin,

I see what I did now I uploaded the wrong file! Should be fixed now.

I'll try and get onto those interrupts for you too.

Re: PIC18F27K42 - UART

Posted: Fri Oct 25, 2019 12:15 pm
by medelec35
Hi Ben,
Thank you
Yes UART is now working with the latest update.
Benj wrote:I'll try and get onto those interrupts for you too.
That's great thanks.