I’m using LPC1788 MCU with KeilV5 compiler.
I Have a Timer ISR in which I read a value form specific ADC channel and write it into a SD-Card using FATFS library.
Here is my Timer ISR code:
void TIMER1_IRQHandler(void){
if (TIM_GetIntStatus(LPC_TIM1, TIM_MR1_INT)== SET){
ADC_Init(LPC_ADC,838);
ADC_ChannelCmd (LPC_ADC,0,ENABLE);
while (!(ADC_ChannelGetStatus(LPC_ADC,0, ADC_DATA_DONE)));
ADCResult = ADC_ChannelGetData(LPC_ADC,0);
sprintf(OutputSample,"%ld\r\n",ADCResultScaled);
f_lseek(&File1, f_size(&File1));
//f_write(&File1,OutputSample,strlen(OutputSample), &FilePointer);
Counter++;
TIM_ClearIntPending(LPC_TIM1, TIM_MR1_INT);
}
}
There is no problem with above code but when I remove the comment sign from the f_write function, program stops and nothing executes exactly after Timer1 is enabled. (referred to debug, after TIM_Cmd(LPC_TIM1, ENABLE) is executed in main function)
So I can’t write the data into the SD-Card in Timer's ISR.
I should mention that f_write function works fine outside the Timer ISR.
Can you guess where is the problem?
Thanks in advance.