| Author | beginning argument ( Replies received: 1 ) |
| orion |
Posted 06-03-2008 at 22:41   |

Registered on : 03-03-2008
Messages : 5
OFF-Line
|
Hi,
I run the following code immediately after main.
void CAN_Configuration(void)
{
CAN_TypeDef *CB = (CAN_TypeDef *) CAN_BASE;
CanTxMsg Transmit;
CAN_InitTypeDef CAN_InitStruct;
CAN_StructInit(&CAN_InitStruct);
CAN_DeInit();
CAN_Init(&CAN_InitStruct);
...
}
But the CAN never initializes. It always returns CANINITFAILED. It fails the acknowledged check seen in stm32f10x_can.c
/* Request initialisation */
CAN->MCR = CAN_MCR_INRQ;
/* ...and check acknowledged */
if ((CAN->MSR & CAN_MSR_INAK) == 0)
{
InitStatus = CANINITFAILED;
}
I do not have the CAN plugged into anything. Nor does the CAN drive any signals on its DB9 pins. Both signals are constant 5V.
Do I have to plug this into a CAN bus? Since the attributes of the bus aren't set until after initialization, I'd be surprised if this were so.
I've attached a screen dump of the CAN register. The values in the registers are constant throughout the whole initialization. Values of most interest are: CAN_BASE = 0x4000640, MCR = 0x1002, MSR = 0xC0A.
Thanks to anyone who can provide help. I really appreciate it.
Orion Pritchard
| Attachments : | can_mem_map.JPG | | | |
|
|
|
Profile
Quote
|
| orion |
Posted 07-03-2008 at 02:12   |

Registered on : 03-03-2008
Messages : 5
OFF-Line
|
It works better if I turn on the CAN clock before trying to initialize.
Doh!!
I added
RCC_APB1PeriphClockCmd(RCC_APB1Periph_ALL, ENABLE);
in the RCC enable routine.
|
|
|
Profile
Quote
|