Results 1 to 2 of 2

Thread: STM32F042F6P6 CAN initialization problem

  1. #1
    Join Date
    Nov 2019
    Location
    ShenZhen
    Posts
    3
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default STM32F042F6P6 CAN initialization problem

    When I use STM32F042F6P6 for initialization, it doesn't come out here, and IO is redirected to PA11 and PA12. Why?

    while (((CANx-> MSR & CAN_MSR_INAK) == (uint16_t) CAN_MSR_INAK) && (wait_ack! = INAK_TIMEOUT))
    {
    wait_ack ++;
    }
    Who can teach me?

  2. #2
    Join Date
    Nov 2019
    Location
    ShenZhen
    Posts
    3
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default

    This is the initial setting:

    static void CAN_GPIO_Configuration (void)
    {
    GPIO_InitTypeDef GPIO_InitStructure;
    SYSCFG-> CFGR1 | = SYSCFG_CFGR1_PA11_PA12_RMP; // RMAP
    RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOA, ENABLE);
    / * CAN1 Periph clock enable * /
    RCC_APB1PeriphClockCmd (RCC_APB1Periph_CAN, ENABLE);
    GPIO_PinAFConfig (GPIOA, GPIO_PinSource12, GPIO_AF_4);
    GPIO_PinAFConfig (GPIOA, GPIO_PinSource11, GPIO_AF_4);
    / * Configure CAN pin: RX * / // PA11
    GPIO_InitStructure.GPIO_Pin = CAN_RX;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_Init (GPIOA, & GPIO_InitStructure);
    / * Configure CAN pin: TX * / // PA12
    GPIO_InitStructure.GPIO_Pin = CAN_TX;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init (GPIOA, & GPIO_InitStructure);
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •