sebasira

MSCAN Problem

Discussion created by sebasira on Feb 11, 2009
Latest reply on Mar 23, 2011 by David Wright
Hello! I've downloaded the MCF51JM msCAN Driver from Freescale's website, but I cant get it to work in the DEMOJM board with the JM128 daugther card.

Jumper Selection for the Board as the default in the DEMOJM User Manual:
- CAN to work at high speed
- Rx and Tx enable
- CAN Enable

I'm going to develope a new application with CAN but I can't make it work!

I manage to config a Message Buffer, with "CAN_ConfigMB", then I load the data with "CAN_LoadMB" and then I transmit it with "CAN_TransmitMB", but then I check the status of the sent messsage buffer and it's QUEUED2 wich means that the data has been copied to a CAN buffer but the transmission was never completed!

Here's the code I use:

  Init_MCG();                           // Clock initialization
 
  Init_LED();                           // LED initialization
 
  Init_Button();                        // Button initialization
 
  EnableInterrupts;                 // Enable Interruptes
 
 
  CAN_Init(FAST);                 // MSCAN Fast Initialization



  for(;:smileywink: {
    __RESET_WATCHDOG();                 // Feed the DOG
   
      ERROR_CODE = CAN_ConfigMB(1,TXDF,1);
   
      DATA_BUFFER[0] = 3;                  // Data Length Code
      DATA_BUFFER[1] = 0x17;            // Data 1
      DATA_BUFFER[2] = 0x05;            // Data 2
      DATA_BUFFER[3] = 0x85;            // Data 3
     
      ERROR_CODE = CAN_LoadMB(1,DATA_BUFFER);   
     
      ERROR_CODE = CAN_TransmitMB(1);
     
      while ( status[0] != TRANSMITTED){
        __RESET_WATCHDOG();             // Feed the DOG
        ERROR_CODE = CAN_CheckStatusMB(1, status );
      }
    
      ERROR_CODE = 0;     <--------- I place a BREAKPOINT HERE and it never reach it!!!
}

That's part of the code (in fact, I don't do that in the LOOP, I do it if a button is pressed, but I deleted
that part so the code was simpler)

In every sentece ERROR_CODE = ERR_OK so no error has ocurrer but the it gets stuck in the while loop
because the status freezes on QUEUED2

How can I solve that?

I also try the sample code that comes with the MCF51JM msCAN Driver, and it gets stuck in the same part with the same status value.

I forget the CAN Registers values:
CANCTL0 = 0x14
CANCTL1 = 0x84
CANBTR0 = 0xC7
CANBTR1 = 0xC5
CANIDAC = 0x00

Any help is appreciated!! Thanks in advance!

PS: Here you can find the MCF51JM msCAN Driver: https://www.freescale.com/webapp/Download?colCode=MSCAN_MCF51JM&appType=license&location=null&fsrch=1
When you extract the ZIP file, under the folder "man" you'll find the manul for this driver

Outcomes