Forum: µC & Digital Electronics Initialization of CANIF (AVR32)

von B0bbyR4y (Guest)

Rate this post
0 useful
not useful
i'm trying to use the CAN Interface of my AT32UC3C.
The Problem is i'm not able to manage it to activate the channel. I been 
engaged in the data sheet and i'm quite sure i did exactly as stated in 
the data sheet.

As you can see below i wrote the CANCTRL Register in the variable 
canctrl_status. I was monitoring that variable to confirm that the 
correct value is written in the CANCTRL Register. This is the case and i 
can't see any Problem there. Following i programmed a Loop to poll the 
variable channel_status. This variable contains the channel enable 
Status flag (CANSR.CES). As soon as the channel enable status flag is 
set (by hardware) the programm should Exit the loop but thats not 

What did i Forget? What's wrong about the code?

I would be thankful for any help!
//----- Channel configuration (Bit time / SamplingMode / OperatingMode / OverrunMode / Memory pointer -----//  
  if(CANIF_channel_enable_status(ch1) == 1)        //If channel enabled
    CANIF_disable(ch1)                  //Disable channel to write the CANCFG register (S. 764)
    while((AVR32_CANIF.channel[1].cansr & AVR32_CANIF_CANSR_CES_MASK) == 1);  //Wait until channel is disabled
  CAN_clear_init(ch1)        //Clear INIT to write the CANCTRL register (S. 766)
  if(((&mobch0[63]) != mobch1) && (mobch0 != (&mobch1[63])))    //Assure that memory spaces do not overlap
    CANIF_set_ram_add(ch1, (unsigned long) mobch1)        //Set start address of RAM for channel[1]
  //For bit time=25*TQ -> baud rate=500kHz --> bit time is set to 17*TQ so baud rate is higher than 500kHz
  CANIF_set_channel_mode(ch1, CANIF_CHANNEL_MODE_LOOPBACK)
  //----- Channel handling (Initialization / Enabling / Overload Frame / Errors / Wake-up mode) ----------//
  CAN_set_init(ch1)              //initialization request
  CAN_clear_init(ch1)            //release initialization
  CANIF_enable(ch1)              //Enable (restart) channel 1

canctrl_status = CAN_get_canctrl(ch1);
channel_status = CANIF_channel_enable_status(ch1);


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.