AtóT90CAN128 CAN_IT stopped working

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0



Im working on a bigger project on this controller, and i managed to get it up and running. Data sending works absolutely fine, but at some point my data reception went off the grid, and stopped working entirely. I think i initialised all the registers correctly, but the ISR routine wont even start. My goal is now to listen to any received messages with message object 0. I will try to unwrap my functions to explain how the code works, so here it goes.


My ISR routine:


CAN_message RX_message;
uint8_t can_it_flag = 0;


    uint8_t        save_canpage;
    uint8_t        mob;
    //Saving the canpage
    save_canpage    = CANPAGE;
    USART_Send_String("MESSAGE \r\n");
    LED3_state = ON;

    mob     = CAN_getMOBInterrupt();

    if(mob == NOMOB){
    //Getting data from MB
    RX_message.length = CAN_getLength(mob);    
    CAN_getData(&RX_message); = CAN_getID();

    //Setting flag to communicate with main
    can_it_flag = 1;
    //clearing IT bit
    clearbit(CANSTMOB, RXOK);
    CAN_setMode(RECEIVE_DATA, RX_message.length);
    //restoring the canpage
    CANPAGE        = save_canpage;    


I wont describe the functions, because the "MESSAGE \r\n" never appears on screen, so it's safe to say that the ISR routine won't even start. My initialization of the CAn looks something like this:


uint8_t        mob;


for (mob = 0; mob < NO_MOBS; mob++)

        CANPAGE  = (mob << 4);
        CANSTMOB = 0;
         CANCDMOB = 0;


//Setting Baudrate


CANBT1        = 0x02;
CANBT2        = 0x0c;
CANBT3        = 0x37;


//Enable receive interrupts

setbit(CANGIE, ENIT);
setbit(CANGIE, ENRX);
clearbit(CANGIE, ENTX);




while (!getbit(CANGSTA, ENFG));


//Select MOB0

CANPAGE    = (0 << 4);


//Enable IT


setbit(CANIE2, IEMOB0);


//Mask is 0, so we will see any incoming messages


CANIDM4 = 0x05;
CANIDM3 = 0;
CANIDM2 = 0;
CANIDM1 = 0;


//ID is the same


CANIDT4 = 0x05;
CANIDT3 = 0;
CANIDT2 = 0;
CANIDT1 = 0;


CANCDMOB = 0b10000110;










However, the can_it_flag is never set (bc. the ISR function never starts...)


What am I doing wrong? I printed all the registers I could think of, but, all of them seems to be fine. Yet when i try to receive data, nothing happens. The hardver is OK, we tested the same setup with an other code, and it sends and receives perfectly...


My printed registers:



CANIE1: 0x00

CANIE2: 0x05

CANEN2: 0x01




Thanks for any help, regards