Hola a todos, os llevo siguiendo bastante tiempo, y estoy empezando a poner en práctica un proyecto CAN, para eso este hilo me ha venido fenomenal, pero me ha surgido un problemilla... Vereis, para ir iniciandome, he decidido hacer un receptor de mensajes CAN, y lo que reciba que lo envíe por RS232, al otro lado del bus can tengo una placa del trabajo que envía mensajes can cada 5sg a una velocidad de 50kb. Siguiendo con breakpoints, veo que no me entra al "if ( can_kbhit() )", alguien me puede echar una mano? El código es el siguiente:
#include <18F2580.h>
#device ICD=TRUE
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV21 //Brownout reset at 2.1V
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
//#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOIESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES BBSIZ1K //1K words Boot Block size
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES NOLPT1OSC //Timer1 is not configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=22110000)
#define CAN_DO_DEBUG TRUE
#define set_50k_baud
#include <can-18F4580.c>
void main()
{
struct rx_stat rxstat;
int32 rx_id;
int buffer[8];
int rx_len;
int i;
for(i=0;i<8;i++)
{
buffer[i]=0;
}
printf("\r\n\r\nCCS CAN EXAMPLE\r\n");
can_init();
while(TRUE)
{
if ( can_kbhit() )
{
printf("\n\rEntro al kbhit\n\r");
printf("\r\n");
if(can_getd(rx_id, &buffer[0], rx_len, rxstat))
{
printf("Byte 0: %X\r\n",buffer[0]);
}
}
}
}
Muchas gracias!!