/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / MEMS SPI interface and interrupts

Username:     
Password:     
             

Forum

# 1   2010-03-10 02:07:01 MEMS SPI interface and interrupts

commlinx
New member
Registered: 2010-02-08
Posts: 3

MEMS SPI interface and interrupts

I'm working on an application under Circle OS and disable timer2 and use timer3 to sample the accelerometer at 640Hz, although have tried lower rates. I'm also receiving serial data over USART2, originally I had it set to a lower priority and the accelerometer was fine but I'd drop some serial characters. Now I've set the the USART to a higher priority I can receive serial data OK but as soon as the serial stream starts the accelerometer starts reading zero on all channels.

I've copied the accelerometer code used by CircleOS 3.8 and because it uses the hardware SPI interface I wouldn't expect and interrupt during the read process to cause a problem? I've stripped back my USART routine to the following and still have the problem:

void USART2_IrqHandler(void) __attribute__ ((interrupt ("IRQ")));
void USART2_IrqHandler(void)
{
    GPS_char = USART_ReceiveData(USART2) & 0x7F;
}

void TIM3_IRQHandler( void ) __attribute__ ((interrupt ("IRQ")));
void TIM3_IRQHandler( void )
{
    MEMS_Read(&OutX, &OutY, &OutZ);
}

I'm configuring the IRQ priorities as follows, I won't include other code for the moment because everything works with the rest of the code until both interrupts are firing at the same time:

NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

Does anyone have any ideas? I guess I could also take a look at using DMA althugh would prefer to get this working if it's something simple.

Offline

 

Board footer