AnsweredAssumed Answered

UART4 MPU fault exception

Question asked by wang.feng.005 on Oct 20, 2015
Latest reply on Nov 20, 2015 by wang.feng.005

I use the UART4 of stm32f103ZGH6 on my application board as a RS 232 port. When I load the main app program with Keil uVision4 into the target flash starting at 0x08000000, the RX/TX of UART4 work fine. However, if I load the app program into the flash starting at 0x08010000 because I want to reserve 64K starting at 0x08000000 for boot loader program, the TX of UART4 still works, but the RX causes the MemManager_Handler exception before calling the UART4_IRQHandler(). My boot loader program doesn't do anything except jump to the main app program right now. I have USART1 for another RS 232 port in this program, its RX/TX work at both starting address, 0x08000000 or 0x08010000. So my question is whether the UART4 needs some special settings or confirguration. The UART4 code I use is as below. The system is configured for PriorityGroup 4, so I set the interrupt priority of UART4 to 7 and its subpriority to 0.

Thank you for your ideas in advance.

RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);                         

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOC, &GPIO_InitStructure);                         

USART_Init(UART4, USART_InitStructure);

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 7;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn;