PIC18F27K42 - UART

Moderator: Benj

Post Reply
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:

PIC18F27K42 - UART

Post 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]
Attachments
PIC18f27K42.fcfx
(7.79 KiB) Downloaded 180 times
Martin

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: PIC18F27K42

Post 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.

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: PIC18F27K42

Post 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 201 times
If all ok then I'll push to the update system.

Thanks.

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: PIC18F27K42

Post 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.
Martin

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: PIC18F27K42

Post by Benj »

Thanks Martin,

What about this?
PIC_CAL_UART.c
(41.89 KiB) Downloaded 203 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: PIC18F27K42

Post by medelec35 »

You're welcome.
Baud dropped to 151 bits per sec
Martin

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: PIC18F27K42

Post 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 208 times
Let me know how you get on.

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: PIC18F27K42

Post by medelec35 »

Hi Ben,
Thank you.
RX and TX are now working perfect.
Tested at 9600 and 38400 BPS
Martin

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: PIC18F27K42 - UART

Post by Benj »

Thanks :D

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

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: PIC18F27K42 - UART

Post 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
Martin

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: PIC18F27K42 - UART

Post 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.

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: PIC18F27K42 - UART

Post 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.
Martin

Post Reply