cancel
Showing results for 
Search instead for 
Did you mean: 

character array interfering with DMA interrupt

vendeiza89
Associate II
Posted on October 14, 2016 at 07:07

The original post was too long to process during our migration. Please click on the attachment to read the original post.
8 REPLIES 8
Posted on October 14, 2016 at 16:45

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?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
vendeiza89
Associate II
Posted on October 15, 2016 at 08:24

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] = 4095

ADCBuffer[1] = 0

ADCBuffer[2] = 0

ADCBuffer[3] = 0

ADCBuffer[4] = 0

instead of:

ADCBuffer[0] = 4095

ADCBuffer[1] = 4095

ADCBuffer[2] = 4095

ADCBuffer[3] = 4095

ADCBuffer[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] = 0

ADCValue[1] = 0

ADCValue[2] = 0

ADCValue[3] = 0

ADCValue[4] = 0

Edit: In case it helps, here are the addresses of the arrays used:

ADC_Buffer 0x200000c8

ADC_Value 0x200000d4

text 0x200008ac

Hope I clarified everything you asked.

Tim

mark239955_stm1
Associate II
Posted on October 17, 2016 at 08:32

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?

vendeiza89
Associate II
Posted on October 19, 2016 at 01:50

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=false

5.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzcg&d=%2Fa%2F0X0000000bSz%2FFKjAnOxJzp_htvMe0mldrEx5t2ftz0vzDmmi1PIoMds&asPdf=false
Posted on October 19, 2016 at 02:47

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mark239955_stm1
Associate II
Posted on October 19, 2016 at 12:46

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.

Posted on October 19, 2016 at 17:01

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..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
vendeiza89
Associate II
Posted on October 25, 2016 at 05:08

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.