cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeProgrammer UART communication error " Error: Activating device: KO. Please, verify the..."

G-Poulios
Associate II

I am using STM32H563ZI board and trying to develop a UART communication project but I just can't figure how to connect to STM32CubeProgrammer threw UART and always get the error:

" Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again... "

GPoulios_0-1710929109043.png

I am having a issues with the UART in general and can't figure out how to transmit data correctly.

 

2 REPLIES 2
TDK
Guru

The chip must be in bootloader mode before you try to connect. You can do this by holding BOOT0 high during reset. There are other ways as well, outlined in AN2606.

You must connect to pins that are supported by the bootloader, as described in AN2606.

The bootloader using even parity, not none.

STM32 microcontroller system memory boot mode - Application note

 

As an aside, it will be more productive to use an SWD connection to develop your application as it allows for a richer set of programming and debugging features.

If you feel a post has answered your question, please click "Accept as Solution".
G-Poulios
Associate II

I want to be able to both configure, transmit and receive data directly from the registers:

void configPinMode(void)
{
    // RESET PIN MODES
    GPIOD->MODER &= ~((3u << 10)    // CLEAR PD5
                     |(3u << 12));  // CLEAR PD6

    // SET PIN MODES
    GPIOD->MODER |= ((2u << 10)     // SET PD5 TO AF
                    |(2u << 12));   // SET PD6 TO AF
}



void setAF(void)
{
    // RESET ALTERNATE FUNCTION. AFR[1] IS THE
    // ALTERNATE FUNCTION HIGH REGISTER
    GPIOD->AFR[1] &= ~((15u << 20)       // CLEAR PD5 AF
                      |(15u << 24));     // CLEAR PD6 AF

    // SET ALTERNATE FUNCTION
    GPIOD->AFR[1] |= ((7u << 20)         // SET PD5 AF
                     |(7u << 24));       // SET PD6 AF
}


void configUart2(void)
{

    // CONFIGURE USART2 CR1 REGISTER
    // CLEAR BITS
    USART2->CR1 &= ~(USART_CR1_M1       // CLEAR M1 FOR 1 START BIT AND 8 DATA BITS (28)
                    |(0x03 << 26)       // INHIBIT INTERRUPTS AT BITS 26 AND 27     (27/26)
                    |USART_CR1_OVER8    // OVERSAMPLING BY 16                       (15)
                    |USART_CR1_CMIE     // INHIBIT CHARACTER MATCH INTERRUPT        (14)
                    |USART_CR1_MME      // DON'T ENABLE MUTE MODE                   (13)
                    |USART_CR1_M0       // CLEAR M0 FOR 1 START BIT AND 8 DATA BITS (12)
                    |USART_CR1_PCE      // NOT IMPLEMENTING PARITY CONTROL          (10)
                    //|(0x1F << 3)        // INHIBIT INTERRUPTS AT BITS 4 TO 8        (4-8)
                    |USART_CR1_TE       // DON'T ENABLE TRANSMITTER JUST YET        (3)
                    |USART_CR1_RE       // DON'T ENABLE RECEIVER JUST YET           (2)
                    |USART_CR1_UE);     // DON'T ENABLE UART2 JUST YET              (0)

    // CONFIGURE USART CR2 REGISTER
    // CLEAR BITS
    USART2->CR2 &= ~(USART_CR2_RTOEN    // DISABLE RECEIVER TIMEOUT             (23)
                    |USART_CR2_ABREN    // NO AUTOMATIC BAUD RATE DETECTION     (20)
                    |USART_CR2_MSBFIRST // TRANSMIT/RECEIVE LSB FIRST           (19)
                    |(0x03 << 16)       // IDLE STATE HIGH FOR RX/TX PINS       (17/16)
                    |USART_CR2_SWAP     // DON'T SWAP FUNCTION OF RX/TX PINS    (15)
                    |USART_CR2_LINEN    // NO LIN MODE                          (14)
                    |(0x03 << 12)       // 1 STOP BIT                           (13/12)
                    |USART_CR2_CLKEN    // DON'T USE CLOCK WITH UART            (11)
                    |USART_CR2_LBDIE);  // NO LIN BREAK DETECTION INTERRUPT     (6)

    // CONFIGURE USART CR3 REGISTER
    // CLEAR BITS
    USART2->CR3 &= ~(USART_CR3_TCBGTIE  // NO TRANSMISSION COMPLETE BEFORE GUART TIME INTERRUPT (24)
                    |USART_CR3_DEM      // NO DRIVER ENABLE MODE                                (14)
					//|USART_CR3_CTSIE
                    |(0x7F << 3)        // DISABLE VARIOUS IRRELEVANT MODES                     (9-3)
                    |USART_CR3_IREN     // NO IrDA MODE                                         (1)
                    |USART_CR3_EIE);    // INHIBIT ERROR INTERRUPT                              (0)

    // SET BITS
    USART2->CR3 |= (USART_CR3_OVRDIS    // DISABLE OVERRUN FUNCTIONALITY (12)
                   |USART_CR3_ONEBIT);  // USE ONE SAMPLE BIT METHOD     (11)

    // SET BAUD RATE IN BRR REGISTER
    USART2->BRR = 0x116;                   // VALUE THAT SETS BAUD RATE TO 115,200 AT INPUT FREQUENCY OF 4MHZ

    // ENABLE UART
    USART2->CR1 |= (USART_CR1_TE        // ENABLE TRANSMITTER (3)
                   |USART_CR1_RE        // ENABLE RECEIVER    (2)
                   |USART_CR1_UE);      // ENABLE UART2       (0)

}

 

is there a way to bypass the bootloader,

also I see the BOOT0  in the .ioc window but I haven't seen how to configure it in the code or on the board somehow.