2016-10-13 10:07 PM
2016-10-14 07:45 AM
Nothing is jumping out as immediately apparent. Not really using the stack much, so probably not an issue with that.
What compiler and optimization settings are being used?How are you determining the lack of interrupt?Can you toggle a pin rather than break-point?If you stop in the debugger where is it stuck?Does the ADC indicate an overrun, or the DMA an error?2016-10-14 11:24 PM
Hi Clive, thanks for the response.
I'm using CooCox CoIDE, no optimisation (I think).The reason why I think its the lack of interrupt is I added an LED toggle command in the interrupt function. It blinks when the char array line is commented out, and doesn't blink when I run the code with it.I'm not sure how to toggle a pin in debugging mode. I've always used breakpoints only.If I run the debugger without breakpoints and pause it randomly, it shows:No source available for ''_muldf3()''No source available for ''_aeabi_dadd()''No source available for ''_floatsidf()''No source available for ''_divdf3()'' If I run the debugger with breakpoints, the errors above do not appear, while the DMA streaming buffer shows:ADCBuffer[0] = 4095ADCBuffer[1] = 0ADCBuffer[2] = 0ADCBuffer[3] = 0ADCBuffer[4] = 0instead of:ADCBuffer[0] = 4095ADCBuffer[1] = 4095ADCBuffer[2] = 4095ADCBuffer[3] = 4095ADCBuffer[4] = 4095(I connected PC1 - PC5 to a 3V source; These are the values shown when i comment out the character array line)The array I transfer the buffer values to shows:ADCValue[0] = 0ADCValue[1] = 0ADCValue[2] = 0ADCValue[3] = 0ADCValue[4] = 0Edit: In case it helps, here are the addresses of the arrays used:ADC_Buffer 0x200000c8ADC_Value 0x200000d4text 0x200008acHope I clarified everything you asked.Tim2016-10-16 11:32 PM
Set a breakpoint in the DMA interrupt handler. When it's faulting, does it stop there once, then never again? Or does it just never stop there at all?
If it's not stopping, or only stops once, in the DMA interrupt handler, stop it (using another breakpoint) in your main() while(1) loop and inspect the registers (particularly the status registers) for the DMA and ADC. Are any of them reporting errors?2016-10-18 04:50 PM
Hi Mark,
Thank you for your response. I tried replying since you posted but kept getting some proxy error for some reason. Anyway, it never stops in the interrupt handler with a breakpoint. I tried looking at the registers but not sure what I'm supposed to be looking at. Could you point me to the right direction? I included a screenshot of the debugging and also a section of the DMA registers that I think is relevant. Cheers, Tim ________________ Attachments : 1.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I045&d=%2Fa%2F0X0000000bT0%2FdddwBLmKOcINARb53g3ngafBGZ9Nbsgjm9q1KFwyGz4&asPdf=false5.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzcg&d=%2Fa%2F0X0000000bSz%2FFKjAnOxJzp_htvMe0mldrEx5t2ftz0vzDmmi1PIoMds&asPdf=false2016-10-18 05:47 PM
You need to sign into the forum before trying to reply. This has been broken for months...
You might want to double check the Vector Table, and that the IRQ Handler is actually named/defined there. Not really make much sense that it isn't getting there. You're not using C++/.CPP to mangle the name. You could add extern ''C'' in front of the DMA2_Stream0_IRQHandler(void) I'd probably make the buffer much bigger, you're going to be generating a lot of interrupts for 5 samples in 3 clocks. Plus you're just copying to another array, better perhaps to DMA directly and alternate halves of the buffer. Not a CooCox user, might be some other tricks or issues with it.2016-10-19 03:46 AM
I doubt it's a CooCox problem. It uses whatever GCC version you point it at, and I've had no problems with its startup or handler code.
2016-10-19 08:01 AM
They have the vectors in a .C file array, if I had headaches with IRQ's not getting called I'd perhap start there and confirm the linkage actually got me to my handler properly. They also don't call SystemInit() in a CMSIS compatible fashion..
2016-10-24 08:08 PM
Hey Mark and Clive,
Thank you both very much for your kind response! I'm sorry for the late update but I've had a crazy week! Anyway back to the topic, I managed to narrow the problem down to these:int main(void)
{ uint16_t Sensor1 = 0; //sensor measurement in millivolts uint16_t Sensor2 = 0; uint16_t Sensor3 = 0; uint16_t Sensor4 = 0; uint16_t Sensor5 = 0; int i = 0; //index char text[20]; //character array that is causing problem RCC_config(); //clock control GPIO_config(); //GPIO configuration DMA_config(); //DMA configuration NVIC_config(); //NVIC configuration ADC_config(); //ADC configuration ADC_SoftwareStartConv(ADC1); //start ADC software conversion while(1) //infinite loop { //convert measurement to millivolts Sensor1 = (ADCValue[i] + 1)/pow(2, Res) * Vref * 1000; i++; Sensor2 = (ADCValue[i] + 1)/pow(2, Res) * Vref * 1000; i++; Sensor3 = (ADCValue[i] + 1)/pow(2, Res) * Vref * 1000; i++; Sensor4 = (ADCValue[i] + 1)/pow(2, Res) * Vref * 1000; i++; Sensor5 = (ADCValue[i] + 1)/pow(2, Res) * Vref * 1000; counter++; //increment iteration counter i = 0; //reset index } } So the character array can be defined and the ADC/DMA interrupt works perfectly fine if the math function powis not used, and vice versa. I don't understand why. And I know there are several other methods to compute the power of an integer, but I really hope to find out why this is a conflict. Cheers.