cancel
Showing results for 
Search instead for 
Did you mean: 

Error in UART4/UART5 in NUCLEO STM32F103RB

Muzahir Hussain
Associate III
Posted on January 17, 2018 at 21:51

When I initialize UART4 registers in STM32 micro-controller, I get this error, 

*** error 65: access violation at 0x40004C0C : no 'read' permission

*** error 65: access violation at 0x40004C0C : no 'write' permission

Here's the code:

&sharpdefine UART4_SR (*((volatile unsigned long*) 0x40004C00))     // uart4 status register

&sharpdefine UART4_DR (*((volatile unsigned long*) 0x40004C04))     // uart4 data register

&sharpdefine UART4_BRR (*((volatile unsigned long*) 0x40004C08))   // baudrate register

&sharpdefine UART4_CR1 (*((volatile unsigned long*) 0x40004C0C))   // controll register_1

&sharpdefine UART4_CR2 (*((volatile unsigned long*) 0x40004C10))    // controll register_2

void UART_Init(unsigned int baudrate) //8 bit data, 1 stop bit, no parity bit

{

    RCC_APB1ENR |= 0x00080000; // enable clock for uart 4

    UART4_CR1 |= 0x00002000;       // enable UART

    UART4_CR1 = 0x00000000;        // 8 bit data

    UART4_CR2 = 0x00000000;        // 1 stop bit

    // setting the baudrate

    float calculation = 36000000.0 / ((baudrate)*16);

    UART4_BRR = calculation;

}

int main(void)

{

    UART_Init(9600);

    while(1){

    }

    return (1);

}

USART1,USART2, USART3 works fine. I get this error when I use UART4, UART5.

Why is that? Is it because,this microcontroller might not have UART interface?

#stm32f103rb #memory-mapped-peripherals #uart #nucleo-stm
2 REPLIES 2
Posted on January 17, 2018 at 22:08

>>

Why is that? Is it because,this microcontroller might not have UART interface?

It means your simulator doesn't support them. Debug on the NUCLEO, not the simulator.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 17, 2018 at 22:10

http://www.st.com/content/ccc/resource/technical/document/datasheet/33/d4/6f/1d/df/0b/4c/6d/CD00161566.pdf/files/CD00161566.pdf/jcr:content/translations/en.CD00161566.pdf

 

The Medium Density device has 3 USART, per specifications.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..