Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CCS CAN Library problem

Status
Not open for further replies.

mushfiqur04

Newbie level 4
Joined
Dec 7, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Dhaka, Bangladesh
Activity points
1,324
Dera All,

Following program segment transmit data for the first time after poweron reset and then stops.. Can any body hep me in this regard?

#include <CAN Transmitter_ADC.h>
#define ENABLE_PIN D0
#define RS_PIN D1
#define RW_PIN D2
#define Data4 D4
#define Data5 D5
#define Data6 D6
#define Data7 D7
#include <lcd.c>


#define CAN_USE_EXTENDED_ID FALSE
#include <can-18xxx8.c>

void main()
{
struct rx_stat rxstat;
int32 rx_id;
int in_data[8];
int rx_len;

//send a request (tx_rtr=1) for 8 bytes of data (tx_len=8) from id 24 (tx_id=24)
int out_data[8];
int32 tx_id=25;
int1 tx_rtr=0;
int1 tx_ext=0;
int tx_len=8;
int tx_pri=3;

int i;

lcd_init();

can_init();

lcd_putc("\fCAN Initialized");
Delay_ms(2000);
can_set_mode(CAN_OP_NORMAL);
lcd_putc("\fCAN Initialized to NORMAL Mode");
Delay_ms(2000);

setup_adc_ports(AN0);
setup_low_volt_detect(FALSE);

for (i=0;i<8;i++)
{
out_data=0;
in_data=0;
}
setup_adc(ADC_CLOCK_DIV_32);
setup_adc_ports(AN0);
set_adc_channel(0);
While(true)
{
/*if(can_kbhit())
{
can_getd(rx_id, &in_data[0], rx_len, rxstat);
printf(lcd_putc,"\fID=%u",rx_id);
delay_ms(3000);
}*/
out_data[0]=read_adc();
printf(lcd_putc,"\n%x",&TXB0CON);
delay_ms(1000);
if(can_tbe())
{
if(can_putd(tx_id, &out_data, tx_len,tx_pri,tx_ext,tx_rtr))
{

while(TXB0CON.TXREQ)
{
//printf(lcd_putc,"\n%x",&TXB0CON);
lcd_putc("\fSending Message");
}
printf(lcd_putc,"\fMessage Sent");
//TXB0CON.TXREQ=0;
}
else
{
printf(lcd_putc,"\fMessage Sending");
}

//delay_ms(2000);
}
else
{
printf(lcd_putc,"\fBusy");
//delay_ms(300);
}

}



}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top