CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PCD CAN

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PCD CAN
PostPosted: Fri Jul 10, 2009 11:12 am     Reply with quote

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
ddorling



Joined: 24 Dec 2007
Posts: 13

View user's profile Send private message Send e-mail

PostPosted: Thu Jul 16, 2009 5:50 am     Reply with quote

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
ddorling



Joined: 24 Dec 2007
Posts: 13

View user's profile Send private message Send e-mail

PostPosted: Thu Jul 16, 2009 6:06 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group