PIC18F25Q10 and PIC18F27K42 - No Timers work

Moderator: Benj

Post Reply
ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by ronaldlijs »

Hi guys,

It seems no timers work at all when configured in Flowcode for PIC18F25Q10. I've tried Timer 0, Timer 1 and Timer 2 with the same results.

There is nothing else in the code, just enabling any Timer causes the code not to compile. All other code on my program works fine at the moment.
TMR0.jpg
TMR0.jpg (6.19 KiB) Viewed 6062 times
When compiling the output shows:

Code: Select all

PIC2_PLAYER1_TEST.c: main()
    91:	T0CONbits.T0CS = 0;
	^ (192) undefined identifier "T0CONbits"
	               ^ (196) struct/union required
    92:	T0CONbits.T0SE = 0;
	               ^ (196) struct/union required
    93:	T0CON = (T0CON & 0xF0) | 0x08;
	^ (192) undefined identifier "T0CON"
    95:	INTCONbits.TMR0IE = 1;
	                  ^ (255) not a member of the struct/union ""
	                     ^ (182) illegal conversion between types
int -> volatile union S1339
PIC2_PLAYER1_TEST.c: myisr()
   111:	if ((INTCONbits.TMR0IF) && (INTCONbits.TMR0IE))
	                      ^ (255) not a member of the struct/union ""
	   (255) not a member of the struct/union "" ^
	                  (199) logical type required ^
	                  (199) logical type required ^
   114:	INTCONbits.TMR0IF = 0;
	                  ^ (255) not a member of the struct/union ""
	                     ^ (182) illegal conversion between types
int -> volatile union S1339
(908) exit status = 1
(908) exit status = 1
It's strange as this chip has got a total of 7 timers and not all of them are shown on the "Interrupt on" Flowcode list
Interrupts.jpg
Interrupts.jpg (21.62 KiB) Viewed 6062 times
  • Three 8-Bit Timers (TMR2/4/6) with Hardware Limit Timer (HLT)
    Four 16-Bit Timers (TMR0/1/3/5)
I have the same error with PIC18F27K42:

Code: Select all

Flowcode1.c: main()
    90:	T0CONbits.T0CS = 0;
	^ (192) undefined identifier "T0CONbits"
	               ^ (196) struct/union required
    91:	T0CONbits.T0SE = 1;
	               ^ (196) struct/union required
    92:	T0CON = (T0CON & 0xF0) | 0x08;
	^ (192) undefined identifier "T0CON"
(908) exit status = 1
(908) exit status = 1
Could it be that the configuration fcdx file for these chips is wrong? For this project we also use PIC18F25K50 and PIC16F15345 and we have had no problems with these.... I am unable to use any new chips as these 2 were listed as being compatible with Flowcode 8 :-(

I have checked the Data Sheet and it seems the register should be T0CON0 and not T0CON
Data Sheet Timer0
Data Sheet Timer0
Timer0.jpg (67.31 KiB) Viewed 6053 times
The code generated by Flowcode is:

Code: Select all

	cr_bit(T0CON, T0CS);
	cr_bit(T0CON, T0SE);
	T0CON = (T0CON & 0xF0) | 0x08;
	st_bit(INTCON0, GIE);
	st_bit(PIE3, TMR0IE);
If edit the C code generated and change the timer section to:

Code: Select all

	T0CON0 = 0x80;
All compiles fine... 0x80 is 10000000 enables Timer 0 as 8 bit timer and sets postscaler to 1:1.

I am no C programmer in any way (this is why I use Flowcode), but I feel there is a bug here with Flowcode not generating the correct code maybe?

Help would be appreciated as can't do much on my project without a Timer on both MCUs :-(

Thanks in advance for your kind help!
R

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: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by Benj »

Hello,

Just investigating this for you now. You're right that it's probably a chip definition related issue. Should hopefully be a quick fix.

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: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by Benj »

Hello,

I'm away from my desk today but here are fixed definitions for the devices you mentioned.

Simply copy into your "C:\ProgramData\MatrixTSL\FlowcodeV8\FCD\PIC" directory and restart Flowcode.

I'll get the fixes pushed to the update system for you tomorrow.
18F25Q10.fcdx
(38.96 KiB) Downloaded 198 times
18F27K42.fcdx
(46.76 KiB) Downloaded 185 times

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by ronaldlijs »

Hi Ben!

I've been away for a few days, just came back today...

MANY thanks for your prompt reply, will give these files a try and let you know the results.

Best regards,
R

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by ronaldlijs »

Hi Ben,

OK, for PIC18F25Q10 tried with only 1 Timer enabled at first and nothing else in the code:

Code: Select all

PIC2_PLAYER1_TEST2.c: main()
    90:	T0CON1 = (T0CON & 0xF0) | 0x00;
	          ^ (192) undefined identifier "T0CON"
(908) exit status = 1
(908) exit status = 1
Seems the entries on the list are still a bit messed up... there are some duplicates there:
INT_B.jpg
INT_B.jpg (23.17 KiB) Viewed 5995 times
For the second PIC18F27K42, I've enabled All 3 timers and the UART RX0 timer and it compiles fine! :D

Thanks for your help!

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: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by Benj »

Many thanks for letting me know.
OK, for PIC18F25Q10 tried with only 1 Timer enabled at first and nothing else in the code:
Seems the entries on the list are still a bit messed up... there are some duplicates there:
These should both be fixed now with the latest definitions available via the update system.

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by ronaldlijs »

Thanks Ben, great stuff. I've updated Flowcode now (full detabse) and restarted.

The list for PIC18F25Q10 looks good now (thanks):
TMR0_3.jpg
TMR0_3.jpg (27.84 KiB) Viewed 5928 times
However when compiling I get:

Code: Select all

   102:	PIE0bits.TMR0IE = 1;
	                ^ (255) not a member of the struct/union ""
	                   ^ (182) illegal conversion between types
int -> volatile union S149
PIC2_PLAYER1_TEST.c: myisr()
   125:	if ((PIR0bits.TMR0IF) && (PIE0bits.TMR0IE))
	                    ^ (255) not a member of the struct/union ""
	                                         ^ (255) not a member of the struct/union ""
	              (199) logical type required ^
	              (199) logical type required ^
   128:	PIR0bits.TMR0IF = 0;
	                ^ (255) not a member of the struct/union ""
	                   ^ (182) illegal conversion between types
int -> volatile union S176
(908) exit status = 1
(908) exit status = 1
Thanks again!
R

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: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by Benj »

Hello,

What device do you get the compile error on. I can't seem to replicate this here on the Q10 devices.

Maybe I'm using a more up to date version of the XC8 compiler?

Aha, I have replicated on the K42 devices. Fixing now.

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by ronaldlijs »

Hi Ben,

Device is def PIC18F25Q10 28 pin SO package.

Interesting that I am just now trying some RS485 interrupt routine on PIC18F27K42 (the peer to the Q10 master I'm using) and I get a similar error:

This was whilst enabling UART interrupt on receive... with minimum code, just a timer and the RS232 ReceiveByte function...
UART_INT_CODE.jpg
UART_INT_CODE.jpg (15.54 KiB) Viewed 5900 times
UART_RXINT0.jpg
UART_RXINT0.jpg (28.03 KiB) Viewed 5900 times

Code: Select all

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c: FC_CAL_UART_Init_1()
   408:	TXSTAbits.BRGH = 1;
	^ (192) undefined identifier "TXSTAbits"
	               ^ (196) struct/union required
   411:	SPBRG = (((19660800 / (9600)) - 8) / 16);
	^ (192) undefined identifier "SPBRG"
   412:	RCSTA = 0;
	^ (192) undefined identifier "RCSTA"
   423:	RCSTAbits.SPEN = 1;
	^ (192) undefined identifier "RCSTAbits"
	               ^ (196) struct/union required
   426:	TXSTAbits.TXEN = 1;
	               ^ (196) struct/union required
   429:	RCSTAbits.CREN = 1;
	               ^ (196) struct/union required
   437:	PIE1bits.RCIE = 0;
	              ^ (255) not a member of the struct/union ""
	                 ^ (182) illegal conversion between types
int -> volatile union S151
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c: FC_CAL_UART_Uninit_1()
   708:	RCSTA = 0;
	^ (192) undefined identifier "RCSTA"
   709:	TXSTA = 0;
	^ (192) undefined identifier "TXSTA"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c: FC_CAL_UART_Send_1()
   788:	TXREG = nChar;
	^ (192) undefined identifier "TXREG"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c: FC_CAL_UART_Receive_1()
   901:	regcheck = (PIR1bits.RCIF);
	                         ^ (255) not a member of the struct/union ""
	                          ^ (182) illegal conversion between types
volatile union S178 -> unsigned char
	                          ^ (181) non-scalar types can't be converted to other types
   949:	regcheck = (RCSTAbits.FERR);
	            ^ (192) undefined identifier "RCSTAbits"
	                          ^ (196) struct/union required
   952:	dummy = RCREG;
	        ^ (192) undefined identifier "RCREG"
   959:	regcheck = (RCSTAbits.OERR);
	                          ^ (196) struct/union required
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c: 962: too many errors (21)
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]
I am sure you'll get to the bottom of this, let me know please if you need anything else from me.

I had tried last week the latest XC8 compiler I downloaded last week as from a previous thread of yours you mentioned this could be the issue... but with same results... so reverted to the FC8 one:
FC8_COMP.jpg
FC8_COMP.jpg (27.77 KiB) Viewed 5900 times

Code: Select all

C:\Program Files (x86)\Microchip\xc8\v2.05\bin>xc8
C:\Program Files (x86)\Microchip\xc8\v2.05\pic\bin\picc
Microchip MPLAB XC8 C Compiler V2.05
Build date: Dec 20 2018
Part Support Version: 2.05
Copyright (C) 2018 Microchip Technology Inc.
(880) invalid number of parameters. Use "XC8 --HELP" for help
(908) exit status = 1
Regards!
R

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by ronaldlijs »

Hi Ben,

I was wondering if there were any more news on this one?

Thanks!
R

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: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by Benj »

Hello,

I'm looking into the problem for you. It's a substantial change from the usual UART register setup so I'm going slowly to try and avoid creating more problems down the road. Hopefully have a fix for you shortly.

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: PIC18F25Q10 and PIC18F27K42 - No Timers work

Post by ronaldlijs »

Thanks Ben,

Don't spend any more time on this as we are have decided not to use any of these 2 MCUs (and also PIC16F15325 which we were having an interrupt problem as well with) and will be replacing them with PIC18F26K40 which seems to compile well and will simply redesign all our boards to use this MCU.

Plenty of RAM, program memory, EEPROM and most importantly PPS which I've used on the dsPIC33 devices and it's great Micrchip feature! This MCU has got also many timers and even internal 64MHz clock if needed, only at like over £1 each, so great stuff.

Many thanks for your efforts and keep up the GREAT work you have been doing over the past years!

Regards,
R

Post Reply