Question
System Clock, Interrupts and USART data loss
Posted on October 11, 2012 at 20:40
Hello,
I want to share my story about the use of the microprocessor and the problems arising from it. My system consists of a microprocessor ARM Cortex M3 STM32F103RC6 and various peripherals. I use this system to develop a variety of sensors. I use the operating system Keil RTX-RTOS. The main components of the system are USART1 and external ADC. Bluetooth module connect to USART at 115200 baud. By Bluetooth I connect to sensors and receive data via Modbus protocol. External ADC is connected to the microprocessor for SPI1 and I interrogate him with frequency 470 Hz. Processor speed - 24 MHz. The problem is a loss 1 byte of message when sensor receive data through USART. This is not always, but at random, most often when the ADC busiest. The most interesting thing that when I increase the system clock data loss almost disappears. But, it is not acceptable for the sensors, it is a disaster. What could be the reason for such behavior of the system? 1. At first I thought that the ADC interrupt stops the current execution interrupt USART. Therefore there is an overflow, set up a flag ORE, and then loss of 1 byte messages Modbus. Then I set the interrupt priority USART1_IRQ higher than the priority of ADC. It did not work. 2. I thought that interrupt handling USART just takes too long. So long, that at a certain load on the processor, the processing is not time to complete. Then I re-programmed function USART1_IRQ_Handler, that it satisfies the minimum functions (receiving data from USART register DR, notification threads ModbusService). It did not work. When SYSCLK = 72 MHz and ADC is off, data loss is not found, but so far admit. Once reduced SYSCLK once the problem starts. Any ideas?