I was wondering if anybody has come across problems when using both SPI and UART heavily on the ATMega32?
In my application commands are received via the UART and buffered using an interrupt driven routine. These commands are then executed out of the buffer and any required data displayed in the LCD module connected to the SPI port. Now data is coming in at 38400 baud and the display data updated at nearly 3.7MHz.
What I had been experiencing were lost bytes of incoming data with the processor heavily loaded, and I had assumed that data was not being buffered correctly due to something I had done in software. However, a simple test showed that the UART buffer overrun flag was being set reasonably often. After an awful lot of head scratching/ banging, I disabled global interrupts just before and after writing data to the SPI register...... And this cures the problem. No missed bytes and no buffer overrun.
I am using date code 48/03 ATMega32-16AI TQFP parts. They run at 14.7468MHz @ 5V. All code is written in 'C' and compiled using Imagecraft 6.30D, which has been verified to generate the expected assembler output.
Whilst the work around is OK for now, I cannot see anything anywhere which describes the potential for this issue. I have put the question to Atmel, but it is still early days for a response by them. So I was wondering if any of you guys can shed some light upon this. Surely I cannot be the only person seeing this?
I look forward to some enlightened answers. And just plain old answers too!