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 support@ccsinfo.com

CANBUS & PIC30F4013 & MAX3051

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



Joined: 10 Sep 2003
Posts: 29

View user's profile Send private message

CANBUS & PIC30F4013 & MAX3051
PostPosted: Mon May 25, 2009 10:25 am     Reply with quote

hi
I am working with canbus communication to interact with a vehicle obdbus.
Now currently I am just trying to get CAN bus to communicate with another unit (eval unit from scantool.net) but however I cannot read any data from the unit nor I can't even get rxcan to function properly.
Can anybody give me some guidance or pointers? What I should look for etc...

Here is my test code...
Code:

#include <can-dsPIC30.c>

int8 buffer[8];
int8 rxdata[20];

#int_CAN1
CAN1_isr()
{
   delay_ms(1);
}

void canSetBaud(void)
{
   can_set_mode(CAN_OP_CONFIG);   
   C1CFG1=0x0001;
   C1CFG2=0x05B8;
   C1RX0CON.dben=FALSE;   
   can_set_mode(CAN_OP_NORMAL);
}

void main()
{
int32 id = 0xAFAFAFAF;
int8 len;

SCL=0;
SDA=1;
mdm_rx=1;
mdm_tx=0;

enable_interrupts(INT_CAN1);
enable_interrupts(GLOBAL);

init_obd(); //hardware setup
can_init();//firmware from the drive ds30pic
canSetBaud();//this is used switch the frq to 250khz at 16mhz crystal

   buffer[0] = 0x00;  just dum data
   buffer[1] = 0x11;
   buffer[2] = 0x22;
   buffer[3] = 0x33;
   buffer[4] = 0x44;
   buffer[5] = 0x55;
   buffer[6] = 0x66;
   buffer[7] = 0x77;

while(1){
can_putd(id,buffer,8,3,TRUE,FALSE);
delay_ms(1000);
}

}
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