Hi !
Before buying I want to check how inserts in C work. PIC16F18887. I create an interrupt to use the capture tool and a macro. As a result, the compiler reports errors - test_18877_c_code.c:97:1: error: (192) undefined identifier "ccpr1h" test_18877_c_code.c:98:1: error: (192) undefined identifier "ccpr1l" and further when accessing registers.
FC 5 it worked. FC 10 what am I doing wrong? Or how to make inserts in C work
Inserts in C do not work.
-
- Posts: 28
- http://meble-kuchenne.info.pl
- Joined: Sun Jan 01, 2023 11:01 am
- Location: UA
- Been thanked: 3 times
- Contact:
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: Inserts in C do not work.
Try in caps so CCPR1H.
Note that you can also access parts of the register using
REGNAMEbits.FIELD = 0b10 where REGNAME is the register (OSCCON for example ) and field is the named subsection.
Is that doesn't work please post your code for us to take a look at.
Martin
Note that you can also access parts of the register using
REGNAMEbits.FIELD = 0b10 where REGNAME is the register (OSCCON for example ) and field is the named subsection.
Is that doesn't work please post your code for us to take a look at.
Martin
Re: Inserts in C do not work.
I don't write in C. I use what is freely available. This was tested on FC5. Changing to capital letters didn't help. I'll try to check your version. Thank you.
Costom interupt properties
Enable Code:
ccpr1h=0;
ccpr1l=0;
ccp1con=0x05;
Handler Code:
if (ts_bit(pir1, CCP1IF))
{
FCM_%n();
cr_bit(pir1, CCP1IF);
}
Macro
FCV_IMP=ccpr1l | ccpr1h<<8;
if (ccp1con&1)
{
FCV_IMPFULL = FCV_IMP - FCV_IMPRIS;//no
FCV_IMPRIS=FCV_IMP;//yes
ccp1con.0=~ccp1con.0;
Costom interupt properties
Enable Code:
ccpr1h=0;
ccpr1l=0;
ccp1con=0x05;
Handler Code:
if (ts_bit(pir1, CCP1IF))
{
FCM_%n();
cr_bit(pir1, CCP1IF);
}
Macro
FCV_IMP=ccpr1l | ccpr1h<<8;
if (ccp1con&1)
{
FCV_IMPFULL = FCV_IMP - FCV_IMPRIS;//no
FCV_IMPRIS=FCV_IMP;//yes
ccp1con.0=~ccp1con.0;
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: Inserts in C do not work.
CCPR1H=0;
CCPR1L=0;
CCP1CON=0x05;
Compiles AOK
Please post your code as an attachment (just a snippet that enables the interrupt handler and it's 'macro') - not sure what you mean by Macro - and how this is laid out.
Martin
CCPR1L=0;
CCP1CON=0x05;
Compiles AOK
Please post your code as an attachment (just a snippet that enables the interrupt handler and it's 'macro') - not sure what you mean by Macro - and how this is laid out.
Martin
Re: Inserts in C do not work.
test_18877_c_code.c:98:8: error: (195) expression syntax
test_18877_c_code.c:127:1: error: (192) undefined identifier "CCP1H"
test_18877_c_code.c:128:1: error: (192) undefined identifier "CCP1L"
test_18877_c_code.c:154:1: error: (192) undefined identifier "FCM_"
(908) exit status = 1
It doesn't work for me. It's impossible to check in general. Maybe Matrix will do capture and comparison and embed it into the FC10 body? Useful tool
test_18877_c_code.c:127:1: error: (192) undefined identifier "CCP1H"
test_18877_c_code.c:128:1: error: (192) undefined identifier "CCP1L"
test_18877_c_code.c:154:1: error: (192) undefined identifier "FCM_"
(908) exit status = 1
It doesn't work for me. It's impossible to check in general. Maybe Matrix will do capture and comparison and embed it into the FC10 body? Useful tool
- Attachments
-
- Test18877.rar
- (63.05 KiB) Downloaded 73 times
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: Inserts in C do not work.
There are several issues stopping this compiling.
The registers in enable are incorrect
CCP1H=0;
CCP1L=0;
Should be CCPR1H and CCPR1L (as per initial query)
Also you have FCM_%N -> which should be FCM_%n (lower case 'n')
Unfortunately Flowcode doesn't have TS / ST/ CR _Bit
So for example
IF(TS_BIT(PIR1,CCP1IF)); (Note the ';' at the end is incorrect and IF should be lower case)
Would be
if(PIR1 & (1 << CCP11F))
However CCP11F doesn't seem to be a field of the PIR1 register and so this should probably be
See https://www.flowcode.co.uk/wiki/index.p ... -_PICmicro for details of custom interrupts...
There are similar issues with
ST_BIT(INTCON,PEIE);
ST_BIT(PIE1,CCP1IE);//capture
Would be:
INTCONbits.PEIE = 1;
PIE1bits.CCP1IE = 1; // There is an issue with register names / field names here
See the data sheet at https://ww1.microchip.com/downloads/aem ... 01825F.pdf
Martin
The registers in enable are incorrect
CCP1H=0;
CCP1L=0;
Should be CCPR1H and CCPR1L (as per initial query)
Also you have FCM_%N -> which should be FCM_%n (lower case 'n')
Unfortunately Flowcode doesn't have TS / ST/ CR _Bit
So for example
IF(TS_BIT(PIR1,CCP1IF)); (Note the ';' at the end is incorrect and IF should be lower case)
Would be
if(PIR1 & (1 << CCP11F))
However CCP11F doesn't seem to be a field of the PIR1 register and so this should probably be
Code: Select all
if(PIR2 & (1 << C1IF)) {
FCM_%n();
PIR2bits.C1IF = 0; // Clear interrupt flag
}
There are similar issues with
ST_BIT(INTCON,PEIE);
ST_BIT(PIE1,CCP1IE);//capture
Would be:
INTCONbits.PEIE = 1;
PIE1bits.CCP1IE = 1; // There is an issue with register names / field names here
See the data sheet at https://ww1.microchip.com/downloads/aem ... 01825F.pdf
Martin
Re: Inserts in C do not work.
Thank you for the lesson. I have made corrections. If I understood everything correctly, it looks like this
//syntax err
Real project on chip 16F913. Checked on FC8. There the compiler swears only on this ccp1con.0=~ccp1con.0; or CCP1CON.0=~CCP1CON.0 //syntax err
- Attachments
-
- Test18877.rar
- (63.51 KiB) Downloaded 68 times
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: Inserts in C do not work.
Possibly use:
CCP1CONbits.CCP1M0
Or just CCP1CON &= -1; if you just want to clear bit 0 of the register.
Note this is better as:
CCP1CON &= - (1 << CCP1M0) ;
Saves a trip to the datasheet to see what is being changed...
Martin
CCP1CONbits.CCP1M0
Or just CCP1CON &= -1; if you just want to clear bit 0 of the register.
Note this is better as:
CCP1CON &= - (1 << CCP1M0) ;
Saves a trip to the datasheet to see what is being changed...
Martin
Re: Inserts in C do not work.
Thank you. Just wonderful! Another error gone. Now we just have to defeat this one;
TRISA=0;
PORTA=0;
T1CON=0x01
INTCONbits.PEIE=1;
PIE1bits.CCP1IE=1;
Compiler err
143: TRISA=0;
^ (195) expression syntax
146: INTCONbits.PEIE=1;
^ (195) expression syntax
(908) exit status = 1
(908) exit status = 1
I noticed that such insertions in C change the main code created by the standard method Flowcode . {} ; are moved
TRISA=0;
PORTA=0;
T1CON=0x01
INTCONbits.PEIE=1;
PIE1bits.CCP1IE=1;
Compiler err
143: TRISA=0;
^ (195) expression syntax
146: INTCONbits.PEIE=1;
^ (195) expression syntax
(908) exit status = 1
(908) exit status = 1
I noticed that such insertions in C change the main code created by the standard method Flowcode . {} ; are moved
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: Inserts in C do not work.
Missing semicolon after T1CON = 0x01
Note the 'bits' refers to bitfields not individual bits.
So
REGISTERbits.FIELD = 0b110;
Will set 3 bits (assuming FIELD is 3 bits wide)
Martin
Note the 'bits' refers to bitfields not individual bits.
So
REGISTERbits.FIELD = 0b110;
Will set 3 bits (assuming FIELD is 3 bits wide)
Martin