integrating c code
Moderator: Benj
- 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: integrating c code
Hi Ondra,
I've sent you a PM so we can try and get this sorted.
I've sent you a PM so we can try and get this sorted.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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: integrating c code
Hi Ondra,
I still seem to be missing some of the required files.
IPtest.c(159): Unable to open include file: config.h
IPtest.c(160): Unable to open include file: sp.h
IPtest.c(161): Unable to open include file: sp.c
IPtest.c(162): Unable to open include file: spi.h
IPtest.c(163): Unable to open include file: spi.c
IPtest.c(164): Unable to open include file: SRAM.h
IPtest.c(165): Unable to open include file: SRAM.c
stack\stackmain.h(14): Unable to open include file: stackconf.h
IPtest.c(170): Unable to open include file: http.h
IPtest.c(171): Unable to open include file: http.c
IPtest.c(172): Unable to open include file: rtc.h
IPtest.c(173): Unable to open include file: rtc.c
stack\eth\ENC28J60.h(30): Unable to open include file: stackconf.h
Would it be better if you simply pointed me to the BoostC project online?
Edit - I found the link from your original post sorry about that. I will let you know how I get on.
I still seem to be missing some of the required files.
IPtest.c(159): Unable to open include file: config.h
IPtest.c(160): Unable to open include file: sp.h
IPtest.c(161): Unable to open include file: sp.c
IPtest.c(162): Unable to open include file: spi.h
IPtest.c(163): Unable to open include file: spi.c
IPtest.c(164): Unable to open include file: SRAM.h
IPtest.c(165): Unable to open include file: SRAM.c
stack\stackmain.h(14): Unable to open include file: stackconf.h
IPtest.c(170): Unable to open include file: http.h
IPtest.c(171): Unable to open include file: http.c
IPtest.c(172): Unable to open include file: rtc.h
IPtest.c(173): Unable to open include file: rtc.c
stack\eth\ENC28J60.h(30): Unable to open include file: stackconf.h
Would it be better if you simply pointed me to the BoostC project online?
Edit - I found the link from your original post sorry about that. I will let you know how I get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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: integrating c code
Right this seems to compile correctly now.
- Attachments
-
- Ccode.zip
- (3.56 MiB) Downloaded 258 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: integrating c code
Good day Ben.
I have a board that uses the 18f6722 device. Trying to compile using this device I got the following errors listed below.
Could you give some guidance on the changes needed to get the code to work with my set up. On my board I have the
chips hardware spi connected to the SRAM and ENC28J60 module. Thanks in advance.
spi.c(13:2): error: unknown identifier 'rpinr21'
spi.c(13:2): error: invalid operand 'rpinr21'
spi.c(13:9): error: failed to generate expression
spi.c(13:13): error: unknown identifier 'rpinr22'
spi.c(13:13): error: invalid operand 'rpinr22'
spi.c(13:20): error: failed to generate expression
spi.c(13:25): error: unknown identifier 'rpor10'
spi.c(13:25): error: invalid operand 'rpor10'
spi.c(13:31): error: failed to generate expression
spi.c(13:36): error: unknown identifier 'rpor9'
spi.c(13:36): error: invalid operand 'rpor9'
spi.c(13:41): error: failed to generate expression
.
rtc.c(20:67): error: unknown identifier 'TMR3CS1'
rtc.c(20:67): error: unexpected '.' operator
rtc.c(20:61): error: failed to generate expression
rtc.c(20:61): error: invalid operand 't3con.TMR3CS1'
rtc.c(20:74): error: failed to generate expression
rtc.c(20:84): error: unknown identifier 'TMR3CS0'
rtc.c(20:84): error: unexpected '.' operator
rtc.c(20:78): error: failed to generate expression
rtc.c(20:78): error: invalid operand 't3con.TMR3CS0'
rtc.c(20:91): error: failed to generate expression
.......................................................................
IPtest.c(410:2): error: unknown identifier 'ancon0'
IPtest.c(410:2): error: invalid operand 'ancon0'
IPtest.c(410:9): error: failed to generate expression
IPtest.c(411:2): error: unknown identifier 'ancon1'
IPtest.c(411:2): error: invalid operand 'ancon1'
IPtest.c(411:9): error: failed to generate expression
IPtest.c(412:2): error: unknown identifier 'cm1con'
IPtest.c(412:2): error: invalid operand 'cm1con'
IPtest.c(412:9): error: failed to generate expression
IPtest.c(413:2): error: unknown identifier 'cm2con'
IPtest.c(413:2): error: invalid operand 'cm2con'
IPtest.c(413:9): error: failed to generate expression
IPtest.c(414:2): error: unknown identifier 'cm3con'
IPtest.c(414:2): error: invalid operand 'cm3con'
IPtest.c(414:9): error: failed to generate expression
IPtest.c success
failure
I have a board that uses the 18f6722 device. Trying to compile using this device I got the following errors listed below.
Could you give some guidance on the changes needed to get the code to work with my set up. On my board I have the
chips hardware spi connected to the SRAM and ENC28J60 module. Thanks in advance.
spi.c(13:2): error: unknown identifier 'rpinr21'
spi.c(13:2): error: invalid operand 'rpinr21'
spi.c(13:9): error: failed to generate expression
spi.c(13:13): error: unknown identifier 'rpinr22'
spi.c(13:13): error: invalid operand 'rpinr22'
spi.c(13:20): error: failed to generate expression
spi.c(13:25): error: unknown identifier 'rpor10'
spi.c(13:25): error: invalid operand 'rpor10'
spi.c(13:31): error: failed to generate expression
spi.c(13:36): error: unknown identifier 'rpor9'
spi.c(13:36): error: invalid operand 'rpor9'
spi.c(13:41): error: failed to generate expression
.
rtc.c(20:67): error: unknown identifier 'TMR3CS1'
rtc.c(20:67): error: unexpected '.' operator
rtc.c(20:61): error: failed to generate expression
rtc.c(20:61): error: invalid operand 't3con.TMR3CS1'
rtc.c(20:74): error: failed to generate expression
rtc.c(20:84): error: unknown identifier 'TMR3CS0'
rtc.c(20:84): error: unexpected '.' operator
rtc.c(20:78): error: failed to generate expression
rtc.c(20:78): error: invalid operand 't3con.TMR3CS0'
rtc.c(20:91): error: failed to generate expression
.......................................................................
IPtest.c(410:2): error: unknown identifier 'ancon0'
IPtest.c(410:2): error: invalid operand 'ancon0'
IPtest.c(410:9): error: failed to generate expression
IPtest.c(411:2): error: unknown identifier 'ancon1'
IPtest.c(411:2): error: invalid operand 'ancon1'
IPtest.c(411:9): error: failed to generate expression
IPtest.c(412:2): error: unknown identifier 'cm1con'
IPtest.c(412:2): error: invalid operand 'cm1con'
IPtest.c(412:9): error: failed to generate expression
IPtest.c(413:2): error: unknown identifier 'cm2con'
IPtest.c(413:2): error: invalid operand 'cm2con'
IPtest.c(413:9): error: failed to generate expression
IPtest.c(414:2): error: unknown identifier 'cm3con'
IPtest.c(414:2): error: invalid operand 'cm3con'
IPtest.c(414:9): error: failed to generate expression
IPtest.c success
failure
- 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: integrating c code
Hello Ondra,
The 18F6722 does not have remappable peripherals, they are fixed in place, so you can safely comment out all of these lines of code.spi.c(13:2): error: unknown identifier 'rpinr21'
The 18F6722 also does not have a RTCC peripheral so is there any way to remove these functions from the program. Does the program need RTCC functionality?rtc.c(20:67): error: unknown identifier 'TMR3CS1'
The final set of errors seem to relate to the ADC and Comparator peripherals. Again are these actually required, Could you replace these with say a Flowcode ADC component which will automatically switch in the correct code for your device?IPtest.c(410:2): error: unknown identifier 'ancon0'
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: integrating c code
Good day Ben. Here is the response form the SourceBoost forum. Could you explain the below in simplified flowcode terms?
Thanks.
1) rpinr21 is something special for the PIC18F27J53. If you use another PIC you'll need to adjust this:
in the config.h you change the "#define spi_port2_conf " to something suitable for your application. Actually you just need to make sure the spi_init() functions initialize the SPI module of your PIC (you can change the function so it works with your PIC).
2) you don't need the RTCC peripheral (the rtc.c code doesn't use it). I've used timer timer 3 for generating a second and tick counter on the PIC. The rtc.c file holds a variable that tells the ammount of seconds passed since reboot (or since 1970) and a variable that holds the total number of clock cycles since reboot. I guess your PIC doesn't have a timer #3 so you'll have to use another one. It's important for TCP.c and some other stack functions to calculate timeouts.
rtc_get_time() //must return number of seconds since reboot (or since 1970 if you are able to sync it in some way).
rtc_get_tick() //number of clock ticks since reboot
rtc_get_tick_div256() //same as above but devided by 256
rtc_get_tick_64k() //same as rtc_get_tick() but devided by 0x1000
3) you can remove the ADC/comparator related stuff for my application it was needed to turn it off in order to make some pins of the chip to work as input or output (check datasheet).
Thanks.
1) rpinr21 is something special for the PIC18F27J53. If you use another PIC you'll need to adjust this:
in the config.h you change the "#define spi_port2_conf " to something suitable for your application. Actually you just need to make sure the spi_init() functions initialize the SPI module of your PIC (you can change the function so it works with your PIC).
2) you don't need the RTCC peripheral (the rtc.c code doesn't use it). I've used timer timer 3 for generating a second and tick counter on the PIC. The rtc.c file holds a variable that tells the ammount of seconds passed since reboot (or since 1970) and a variable that holds the total number of clock cycles since reboot. I guess your PIC doesn't have a timer #3 so you'll have to use another one. It's important for TCP.c and some other stack functions to calculate timeouts.
rtc_get_time() //must return number of seconds since reboot (or since 1970 if you are able to sync it in some way).
rtc_get_tick() //number of clock ticks since reboot
rtc_get_tick_div256() //same as above but devided by 256
rtc_get_tick_64k() //same as rtc_get_tick() but devided by 0x1000
3) you can remove the ADC/comparator related stuff for my application it was needed to turn it off in order to make some pins of the chip to work as input or output (check datasheet).
- 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: integrating c code
Hi Ondra,
For point 1 I would simply open the SPI.c file and comment out all the lines that are causing compile errors. As I say your device does not have the remapping functionality so you can loose all the code that configures it.
The next one is a bit more tricky to do. You could potentially use an external RTC IC to collect the data or a simpler way would be to create a timer interrupt in Flowcode which handles the time and date variables. You would then probably need to create functions that would read the time and date variables in the way the TCP.c requires and then change the function calls in the TCP.c to match your new functions.
Again for the final point get commenting out lines that cause compile errors.
For point 1 I would simply open the SPI.c file and comment out all the lines that are causing compile errors. As I say your device does not have the remapping functionality so you can loose all the code that configures it.
The next one is a bit more tricky to do. You could potentially use an external RTC IC to collect the data or a simpler way would be to create a timer interrupt in Flowcode which handles the time and date variables. You would then probably need to create functions that would read the time and date variables in the way the TCP.c requires and then change the function calls in the TCP.c to match your new functions.
Again for the final point get commenting out lines that cause compile errors.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: integrating c code
Thanks Ben.
I've made changes to the hardware setting to run the code on my system.
I have a 18f6722 using a 10Mhz xtl set to 4x-PLL. I tried running the code on my sytem
and for starters the UART is passing out garbage data. Below is the Serial port init().
Could you have a look to see if there is an issue with the serial_init that may cause my
port to not print at the right baud.
#ifdef USE_HARD_SP
void serial_init(){
//pie1.RCIE=1; //enable interrupts
trisc.6=1; //enable the outputs/inputs
trisc.7=1;
txsta.BRGH=1;
baudcon.BRG16=1;
spbrgh=1249/256; //16bit brg @ 9600 baud
spbrg=1249%256;
txsta.SYNC=0;
rcsta.SPEN=1;
txsta.TXEN=1; //transmit enable
rcsta.CREN=1; //receive enable
//ipr1.RCIP=1; //high interrupt priority
}
I've made changes to the hardware setting to run the code on my system.
I have a 18f6722 using a 10Mhz xtl set to 4x-PLL. I tried running the code on my sytem
and for starters the UART is passing out garbage data. Below is the Serial port init().
Could you have a look to see if there is an issue with the serial_init that may cause my
port to not print at the right baud.
#ifdef USE_HARD_SP
void serial_init(){
//pie1.RCIE=1; //enable interrupts
trisc.6=1; //enable the outputs/inputs
trisc.7=1;
txsta.BRGH=1;
baudcon.BRG16=1;
spbrgh=1249/256; //16bit brg @ 9600 baud
spbrg=1249%256;
txsta.SYNC=0;
rcsta.SPEN=1;
txsta.TXEN=1; //transmit enable
rcsta.CREN=1; //receive enable
//ipr1.RCIP=1; //high interrupt priority
}
- 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: integrating c code
Hi Ondra,
If the high speed mode is enabled then this is the baud calc.
(((CLOCK_SPEED / 9600) - 16) / 16)
For low speed this is the calc.
(((CLOCK_SPEED / 9600) - 16) / 64)
You then need to split into 2 bytes and pass to the spbrg and spbrgh registers.
If the high speed mode is enabled then this is the baud calc.
(((CLOCK_SPEED / 9600) - 16) / 16)
For low speed this is the calc.
(((CLOCK_SPEED / 9600) - 16) / 64)
You then need to split into 2 bytes and pass to the spbrg and spbrgh registers.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: integrating c code
Good day Ben.
Over the weekend with a lot of help from Tom over on the Sourceboost forum, I discovered that the interrupt() routine was not in the code. At some point the interrupt routine must have gotten chopped. It might have been over the issue that when I try to compile with the routine, flowcode returns and error, "void interrupt(){} already has a body". It seem the FC IDE automatically generates an empty interrupt(){}. How can I handle this?
Over the weekend with a lot of help from Tom over on the Sourceboost forum, I discovered that the interrupt() routine was not in the code. At some point the interrupt routine must have gotten chopped. It might have been over the issue that when I try to compile with the routine, flowcode returns and error, "void interrupt(){} already has a body". It seem the FC IDE automatically generates an empty interrupt(){}. How can I handle this?
- Attachments
-
- IPtest.c
- (17.47 KiB) Downloaded 155 times
- 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: integrating c code
Hi Ondra,
The interrupt section is in the
The interrupt section is in the
Code: Select all
section of your FCD. Find the IntStart and IntEnd lines and make them blank - "" and the C version of the interrupt function should then compile correctly.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel