2015-10-20 05:44 AM
Hi,
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;NVIC_Init(&NVIC_InitStructure); USART_ITConfig(UART4, USART_IT_RXNE, ENABLE);USART_Cmd(UART4, ENABLE);UART4_IRQHandler(void);2015-10-20 05:56 AM
Did you redirect the interrupt vector table?
JW2015-10-20 06:31 AM
Per Jan, SCB->VTOR = 0x08010000, check SystemInit() in system_stm32f1xx.c
2015-10-22 07:55 AM
2015-10-22 12:30 PM
Make sure the handler name exactly matches the name called out in the vector table (startup_stm32f1xx.s) and that the linker has bound the two, and the address for the UART4 entry in the table physically points at your code. Look at the .MAP, and the output in the .HEX/.BIN. If you have a disassembly, look at that.
Make sure you haven't mixed UART and USART in the naming.Failing that zip up the whole project and output files, and attach.2015-11-19 02:21 PM
Hi Clive,
I have confirmed the handler name in my app program and in the vector table (startup_stm32f10x_hd.s), and checked the Map file also. The naming seems correct. I just don't know how to bind two in the Linker of Keil uVision as you mentioned. In order to make this problem clear, I delete other functions from my app except USART1, UART4 and UART5 functions. I would summarize my test for your reference.1. If I build a debug version or release version of my app program with the pointer to the vector table 0x08000000, USART1, UART4 and UART5 work correct.2. If I implement a bootloader program first which just jumps to the app start address 0x08010100, and build the release version of my app with pointer to the vector 0x08010100, USART1 TX/RX, UART4 TX and UART5 TX work, but UART4 RX and UART5 RX will trigger the exception MemManage_Handler. I set a signal at beginning of UART4_IRQHandler, but the oscilloscope is not triggered, that means the exception occurs before executing the IRQHandler.By the way, the bootloader's pointer to vector table is 0x08000000.I tried to attach the zip file of whole project for you several times, unfortunately it always showed error. Can you give me another way to email you the zip file? This zip file includes the settings of Keil uVision4. Please let me know whether you need my bootloader project and ST Peripheral Lib 3.4 I use also.Thank you in advance.2015-11-19 03:55 PM
Click on my Avatar/Profile. A Google Drive share would work too.
I'm using v3.5.0, but likely have 3.4.0 if that's the issue. Just send the test app for now, and I'll see if I can figure out what's happening there first.2015-11-20 05:18 AM
My system seems hard to let me access to a share drive.
My email is feng_wang@amat.comCan you email me a message so that I can attach the zip file to email and back to you?Thanks.