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

CAN-not getting anything in RX buffers

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







CAN-not getting anything in RX buffers
PostPosted: Wed Jul 27, 2005 11:35 am     Reply with quote

hi! I'm still having trouble with my PIC18F2480. I'm not getting anything in my RX buffers. Can someone please take a look at my functions. It would be really helpful. I've been using the can18xxx8.c and can18xxx8.h files. I'm also using MCP2551.

Thanks
Arlene



#fuses INTRC_IO, NOLVP, NOMCLR, BROWNOUT, BORV45, NOWDT,NOPBADEN,
PROTECT, CPB, WRTC, EBTRB, EBTR, CPD, IESO, WRTB, WRT//, WRTD


void can_setup()
{
struct rx_stat rxstat;
int data_in[8];
int32 rx_id;
int rx_len;
int data_out[8];
int32 tx_id=24;
int1 tx_ext=0;
int1 tx_rtr=0;
int tx_len=8;
int tx_pri=3;
int length;

for (i=0; i<8; i++)
{
data_out[i]=0;
data_in[i]=0;
}

can_initialize();

if (can_tbe())
{
tx_len=fgetc(streamB);
for (i= 0; i<tx_len; i++)
{
data_out[i]= fgetc(streamB);
}
i= can_putd(tx_id, data_out, tx_len, tx_pri, tx_ext, tx_rtr);
}

else
{
if(can_getd(rx_id, data_in, rx_len, rxstat))
{
for ( i=0; i<rxlen; i++)
{
putc(data_in[i], streamB);
}

}

}
}

void can_initialize(void)
{
can_set_mode(CAN_OP_CONFIG);
can_set_baud_rate(10400);

RXB0CON=0;
RXB0CON.rxm=CAN_RX_VALID;
RXB0CON.rxb0dben=CAN_USE_RX_DOUBLE_BUFFER;
RXB1CON=RXB0CON;

CIOCON.endrhi=CAN_ENABLE_DRIVE_HIGH;
CIOCON.cancap=CAN_ENABLE_CAN_CAPTURE;

can_set_id(RX0MASK, CAN_MASK_ACCEPT_ALL, CAN_USE_EXTENDED_ID);
can_set_id(RX0FILTER0, 0, CAN_USE_EXTENDED_ID);
can_set_id(RX0FILTER1, 0, CAN_USE_EXTENDED_ID);

can_set_id(RX1MASK, CAN_MASK_ACCEPT_ALL,
CAN_USE_EXTENDED_ID);
can_set_id(RX1FILTER2, 0, CAN_USE_EXTENDED_ID);
can_set_id(RX1FILTER3, 0, CAN_USE_EXTENDED_ID);
can_set_id(RX1FILTER4, 0, CAN_USE_EXTENDED_ID);
can_set_id(RX1FILTER5, 0, CAN_USE_EXTENDED_ID);

set_tris_b((*0xF93 & 0xFB ) | 0x08);
can_set_mode(CAN_OP_NORMAL);

}
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Wed Mar 29, 2006 5:34 am     Reply with quote

You know that you're in normal mode right ? And that in normal mode you absolutely need at least two nodes to complete a message.

You should get loopback mode working first.
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