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.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) != mobch1) && (mobch0 != (&mobch1))) //Assure that memory spaces do not overlap
CANIF_set_ram_add(ch1, (unsigned long) mobch1) //Set start address of RAM for channel
//For bit time=25*TQ -> baud rate=500kHz --> bit time is set to 17*TQ so baud rate is higher than 500kHz
//----- 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);