Hi Alex,
I am seeing problem when two external interrupts(ADC int and RF module int) starts to work.
Problem:
When I test without Gateway board, I can read the expected TEMPRATURE values from ADC in interrupt mode as there is no SYNC command sending and RF module interrupt will not trigger as well. The moment when I turn on Gateway board, RF module interrupt triggers whenever it send & receive but ADC temperature values read as zero instead the expected value. couldn't come out of this even if Gateway board switched off again. It is going fine in to ADC handler.
Here is the code:
ADC Handler
int32_t volatile Tsample;
int32_t sample;
volatile bool adc_int=false;
void ad7124_irq_handler(void) //ADC handler
{
adc_int=true;
struct system_pinmux_config pin_conf;
pin_conf.mux_position = 0x03; // Change MISO/EXTINT pin MUX position to Sercom MUX for SPI
system_pinmux_pin_set_config(PIN_PA04, &pin_conf);
ATOMIC_SECTION_ENTER
ret=AD7124_ReadData(ad7124_handler, &sample);
ATOMIC_SECTION_LEAVE
}
main
int main(void)
{
enum ad7124_registers regNr;
irq_initialize_vectors();
system_init();
delay_init();
configure_spi_master(); //ADC spi innterface at 3MHZ sclk
ret = AD7124_Setup(ad7124_handler, AD7124_SLAVE_ID, (ad7124_st_reg *)&ad7124_regs); //ADC functions
if (ret<0)
{
return;
}
ret= AD7124_Calibration(AD7124_SLAVE_ID); //ADC functions
if (ret<0)
{
return;
}
for(regNr = AD7124_Status; (regNr < AD7124_REG_NO) && !(ret < 0); regNr++) //ADC functions
{
ret = AD7124_ReadRegister(ad7124_handler, &ad7124_regs[regNr]); //------------------>Read Register value after Writing
if (ret < 0)
return;
}
port_pin_set_output_level(EXT1_PIN_10,false);
PHY_Init();
NWK_Init(SRC_ADDR);
timer_init();
appInit();
configure_extint_channel();
adc_irq_init((FUNC_PTR)ad7124_irq_handler); //Pointing ADC handler
cpu_irq_enable();
port_pin_set_output_level(EXT1_PIN_10,true); //start conversion
while (1)
{
if (adc_int==true)
{
adc_int=false;
struct system_pinmux_config pin_conf;
pin_conf.mux_position = 0x00; // change back MUX position to EXTINT to detect next RDY
system_pinmux_pin_set_config(PIN_PA04, &pin_conf);
ATOMIC_SECTION_ENTER
Tsample=sample;
ATOMIC_SECTION_LEAVE
channelnum= Tsample & 0x0F;
if(acqptr<50) //Buffer capacity for 10 samples (50 bytes)
{
acqbuf[acqptr++]= MODULE_NO; // MODULE_NO as per Lab view configuraion
acqbuf[acqptr++]= channelnum;
acqbuf[acqptr++]= (Tsample>>24) & 0xFF;
acqbuf[acqptr++]= (Tsample>>16) & 0xFF;
acqbuf[acqptr++]= (Tsample>>8) & 0xFF;
}
if(acqptr==50)
{
acqptr=0;
}
}
Suggest.
Thanks,
Muthu