Skip to main content
Explorer
March 24, 2024
Solved

PA4 and PA5 don't work STM8S208RB

  • March 24, 2024
  • 3 replies
  • 2015 views

Hello,

STM8S208RB microcontroller. Pins PA4 and PA5 do not work in push-pull mode. Why? I haven't tried it in other modes. It's not a microcontroller issue because I tested it on two different microcontrollers. Pins are shown in the datasheet (see figure bellow).

MykolaLevun_0-1711293982148.png

I tested the robotic functionality using this code:
main()
{
    PA_DDR = 0b01111110;
    PA_CR1 = 0b01111110;
    PA_CR2 = 0b00000000;
    PA_ODR = 0b00000000;
    while (1)
    {
        delay_miles(2000);
        PA_ODR = 0b01111110;
        delay_miles(2000);
        PA_ODR = 0b00000000;
    }
}

    This topic has been closed for replies.
    Best answer by MykolaLevun

    The answer to why PA4 and PA5 did not work is in the UM2364 manual in section 6.8 USART communication

     (see figure below).

    MykolaLevun_0-1711346879834.png

     

    3 replies

    Visitor II
    March 24, 2024

    The problem is only with PA4 and PA5?

    Try with other pins.

    PA4 and PA5 are UART1 RX and TX pins. If UART1 is enable it controls these pins.

     

    Explorer
    March 24, 2024

    Works well with other pins. As far as I understand, after the reset the UART1 is turned off, but I didn’t turn it on in software. PA4 and PA5 are always logically 0, checked with an oscilloscope.

    Visitor II
    March 24, 2024

    Maybe bootloader is active and it left UART1 enable. Check UART1 registers or disable UART1.

     

    Explorer
    March 24, 2024

    I checked it in the debugger and UART1 is turned off. I also need to say that I am using a NUCLEO-8S208RB board.

    MykolaLevunAuthorAnswer
    Explorer
    March 25, 2024

    The answer to why PA4 and PA5 did not work is in the UM2364 manual in section 6.8 USART communication

     (see figure below).

    MykolaLevun_0-1711346879834.png