View previous topic :: View next topic |
Author |
Message |
pmuldoon
Joined: 26 Sep 2003 Posts: 218 Location: Northern Indiana
|
PCD CAN |
Posted: Fri Jul 10, 2009 11:12 am |
|
|
I've just stepped up to the PCD family of chips to use the dsPIC30F5013 and the embedded CAN controller. I am getting compile errors. Is there a bug in the code, or am I just doing something wrong?
Also, I need a baud rate of 250Kbps and the CAN_SET_BAUD(void) defaults to 125Kbps. Is there a function that supports different baud rates, or do I just need to do that at the register level via the PIC datasheet?
this:
Code: | #include <30F5013.h>
#include <can-dspic30.c>
#fuses XT,NOWDT,BORV42,,BROWNOUT,PUT64
/********************* MAIN() *****************************
**********************************************************/
void main()
{
int i,j;
for(i=0;i<10;i++)
j=i;
} | causes this:
Quote: | Executing: "C:\Program files\Picc\CCSC.exe" +FD "B772-601.c" +DF +LN +T +A +M +Z +Y=9 +EA
*** Error 12 "C:\Program Files\PICC\drivers\can-dsPIC30.h" Line 239(5,9): Undefined identifier
*** Error 48 "C:\Program Files\PICC\drivers\can-dsPIC30.h" Line 239(10,17): Expecting a (
*** Error 43 "C:\Program Files\PICC\drivers\can-dsPIC30.h" Line 239(0,1): Expecting a declaration
3 Errors, 0 Warnings. |
referencing these lines in .h file:
Quote: | #if getenv("SFR:C2TX0B1")
#word C2TX0B1=getenv("SFR:C2TX0B1")
#word C2TX0B2=getenv("SFR:C2TX0B2")
#word C2TX0B3=getenv("SFR:C2TX0B3")
#word C2TX0B4=getenv("SFR:C2TX0B4")
#word C2TX1B1=getenv("SFR:C2TX1B1")
#word C2TX1B2=getenv("SFR:C2TX1B2")
#word C2TX1B3=getenv("SFR:C2TX1B3")
#word C2TX1B4=getenv("SFR:C2TX1B4")
#word C2TX2B1=getenv("SFR:C2TX2B1")
#239 #word C2TX2B2=getenv("SFR:C2TX2B2")
#word C2TX2B3=getenv("SFR:C2TX2B3")
#word C2TX2B4=getenv("SFR:C2TX2B4")
#endif |
|
|
![](templates/subSilver/images/spacer.gif) |
ddorling
Joined: 24 Dec 2007 Posts: 13
|
|
Posted: Thu Jul 16, 2009 5:50 am |
|
|
Hi
to achieve 250k I had to use an OSC1 speed of 80 Mhz, that is using a 10Mhz external clock with a PLL of 8. This is on a 30f3013. Your clock speed will accomadate a particular set of baud rates. The table is listed in the devices datasheet.
I haven't used CAN yet.
best wishes |
|
![](templates/subSilver/images/spacer.gif) |
ddorling
Joined: 24 Dec 2007 Posts: 13
|
|
Posted: Thu Jul 16, 2009 6:06 am |
|
|
Hi
you may have to set the baud rate divisor bits in the UxBRG register manually if you can't get the setup functions to do it. Baud Rate = FCY / (16*(BRG+1)) is the calculation for the 30f3013
and is explained in the datasheet FCY instruction cycle= clock/4.
best wishes |
|
![](templates/subSilver/images/spacer.gif) |
|