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

dsPIC33 only sends ID of 0x00 on CAN2 when using ext frame

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



Joined: 05 Dec 2011
Posts: 11

View user's profile Send private message

dsPIC33 only sends ID of 0x00 on CAN2 when using ext frame
PostPosted: Tue Aug 05, 2014 8:00 am     Reply with quote

Is there an issue with the CCS compiler being able to correctly compile code to send CAN messages on CAN2 ? I have code that is pretty simple and uses both CAN ports and has identical function calls except CAN2 uses functions for CAN2, but I only get arbID 0x00 on CAN 2 for extended frames....seems to work OK with standard ID (at least with compiler version 4.125).

I just upgraded to the latest compiler version (5.026) yesterday (8/4/2014) in the hopes it would work, but it didn't.

Here is the CAN related code (uC is a 33FJ64GP706A):
Code:

// high-speed CAN, 125 Kbit/sec
//use 1/2 of the clock frequency on MBTime with a dsPIC33
#define CAN_BRG_PRESCALAR 0         
#define CAN_BRG_SYNCH_JUMP_WIDTH 0
 
#define CAN_BRG_PROPAGATION_TIME 2
#define CAN_BRG_PHASE_SEGMENT_1 7
#define CAN_BRG_SAM 0
#define CAN_BRG_SEG_2_PHASE_TS 1
#define CAN_BRG_PHASE_SEGMENT_2 7
#define CAN_BRG_WAKE_FILTER 0

//cluster CAN bus, single wire, 33.333 Kbps
//use 1/2 of the clock frequency on MBTime with a dsPIC33
#define CAN2_BRG_PRESCALAR 2         
#define CAN2_BRG_SYNCH_JUMP_WIDTH 0
 
#define CAN2_BRG_PROPAGATION_TIME 7
#define CAN2_BRG_PHASE_SEGMENT_1 7
#define CAN2_BRG_SAM 0
#define CAN2_BRG_SEG_2_PHASE_TS 1
#define CAN2_BRG_PHASE_SEGMENT_2 7
#define CAN2_BRG_WAKE_FILTER 0
#define CAN_USE_EXTENDED_ID         TRUE

//////////

can_init();
can2_init();
can_set_mode(CAN_OP_CONFIG);                    //must be in config mode before params can be set
can_enable_b_transfer(0);                       //buffers used for tx
can_enable_b_transfer(1);
can_enable_b_transfer(2);
can_enable_b_transfer(3);
can_enable_b_transfer(4);
can_enable_b_transfer(5);
can_enable_b_transfer(6);
can_enable_b_transfer(7);
can_set_mode(CAN_OP_NORMAL); 
can2_set_mode(CAN_OP_CONFIG);                   //must be in config mode before params can be set
can2_enable_b_transfer(0);                      //buffers used for tx
can2_enable_b_transfer(1);
can2_enable_b_transfer(2);
can2_set_mode(CAN_OP_NORMAL);   

while(true)
{
   can2_putd(0x24c, &data, 8, 3, TRUE, FALSE);
   can_putd(0x24c, &data, 8, 3, TRUE, FALSE);
   can2_putd(0x24c, &data2, 8, 3, TRUE, FALSE);
   can_putd(0x24c, &data2, 8, 3, TRUE, FALSE);
   delay_ms(1000);
}

What gives? Why do I only get ArbID on CAN2 ????
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 05, 2014 2:23 pm     Reply with quote

See this thread on the Microchip forum:

Standard ID Sometimes Transmits as 0 (for dsPIC33):
http://www.microchip.com/forums/m434144.aspx


Possibly related -
Strange CAN ID Behaviour:
http://www.microchip.com/forums/m712817.aspx
labviewman



Joined: 05 Dec 2011
Posts: 11

View user's profile Send private message

PostPosted: Tue Aug 05, 2014 6:06 pm     Reply with quote

Interesting posts...pretty frustrating MicroChip has so many issues, but I read the errata for this micro (33FJ64GP706A) but didn't see anything on ECAN that applied to my observation.

CCS tried the code on a PIC24HJ256GP610 which worked perfectly, so I suspect it's a feature of my micro...strange it's not in the errata. I guess I will end up cutting traces and wire the bus to CAN1 which works fine Sad
labviewman



Joined: 05 Dec 2011
Posts: 11

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 9:39 am     Reply with quote

Must have been a problem with the CANoe configuration I was using....tested again with CANalyzer and it worked perfectly....weird
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