Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

dsPIC interrupt & queue

Posted by Ruben_saz on November 17, 2007
I'm having trouble with a interrupt that posts data in a queue. The ADC interrupt is supposed to write 2 words obtained from ADCBUF0 y ADCBUF2 on a queue for further prossesing. The problem is that this causes the device to branch to the _AddressError Trap vector. If I remove this line

xYieldRequired = xQueueSendFromISR( adcValues, &analogReading, xYieldRequired );

from the code. The program runs ok, but obviously i don't get the ADC values on the processing task. Here is the ISR code.

void __attribute__((__interrupt__, auto_psv)) _ADCInterrupt(void)
{
unsigned int analogReading, readCount = 0;
portBASE_TYPE xYieldRequired = pdFALSE;

IFS0bits.ADIF = 0;
while( readCount < 2 )
{
analogReading = ReadADC12(readCount);
xYieldRequired = xQueueSendFromISR( adcValues, &analogReading, xYieldRequired );
readCount++;
}
readCount=0;
if( xYieldRequired != pdFALSE )
{
taskYIELD();
}
}

//END OF ISR CODE
------------------------------------------------

And this is the code for the processing task, in this case it only displays the integer value obtained from the ADC.

for(;;){
asm("btg LATD, #6"); // TOGGLE LED, JUST TO SEE THAT THE TASK IS RUNNING
ADCON1bits.SAMP = 1;// START SAMPLING AND THEN AUTOMATIC CONVERSION
vTaskDelay( 1000 ); // WAIT 1 SECOND (FOR TESTING PURPOSES) ADC INTERRUPT POST DATA
// IN THE QUEUE WITHIN THIS PERIOD OF TIME

if(xQueueReceive( adcValues, &adcData, ( portTickType ) 10 ))
{
v2 = adcData;
}

if(xQueueReceive( adcValues, &adcData, ( portTickType ) 10 ))
{
v1 = adcData;
}

sprintf( cStringBuffer, "V: %d A: %d", v1, v2 ); // Print string to buffer
xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY ); // Send the message to the LCD task
}


I'm running it on a dsPIC30F6014A, and I'm using the MPLAB ICD2, Any help with this will be greatly appreciated.

Cheers!!

RE: dsPIC interrupt & queue

Posted by Richard on November 17, 2007
I cannot see anything that is obviously wrong, on the assumption that cStringBuffer[] is large enough. It could be a stack overflow within the task. Can you try removing the call to sprintf() because when using GCC this is likely to use a LOT of stack. Maybe just set cStringBuffer to a const string to make sure it contains something valid ( strcpy( cStringBuffer, "test" ) ). I know this removes the functionality of seeing the values but will be a good test.

You could try making the task stack bigger too, and ensuring there are no large variables on the stack (is cStringBuffer on the stack).

Any of these things making a difference would indicate a stack issue.

Regards.

RE: dsPIC interrupt & queue

Posted by Ruben_saz on November 17, 2007
Hi Richard!

As you said, the problem was the stack allocated to that task. It seems that it's not good to write programs at late night, one can forget to check such trivial things :D

Thank you very much.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner