karth
Joined: 10 Sep 2003 Posts: 29
|
CANBUS & PIC30F4013 & MAX3051 |
Posted: Mon May 25, 2009 10:25 am |
|
|
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);
}
} |
|
|