This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problems with TSK and HWI



Hello

 

I'm a beginner with DSP/BIOS. I'm using a DSK6455 + 5-6K + ADS1274EVM, CCS v4.2.3 and BIOS 5. I use HWI 13 with event 40 (McBSP0) and one task. The task must work when ISR catch a pointer, but it doesn't work. I've test the code and I think that CSR.GIE bit is disabled when task works, but I'm not sure.

This is my code:

 

#include <std.h>
#include <buf.h>
#include <sem.h>
#include <log.h>
#include <clk.h>
#include <tsk.h>
#include <sys.h>
#include <hwi.h>
#include <stdio.h>
#include <c64.h>

#include <dsk6455.h>
#include "mcbsp.h"

extern LOG_Obj trace;
extern BUF_Obj bufferPool;
extern BUF_Obj bufferFirst;
extern TSK_Obj TSK0;

void main(void)
{

........
C64_disableIER(C64_EINT13);

........

C64_enableIER(C64_EINT13);
          
}


void taskProm()  //The task
{
    int i;
    SEM_pendBinary(&SEM0, SYS_FOREVER);
        for (i=0; i<rate; i++)
        {
            acum = acum + buffPtr_First[i];
        }
        buffPtr_Out [codecPoint] = acum / rate;
        codecPoint++;
        acum=0;
        firstPoint = 0;
        flag=0;
        LOG_printf(&trace, "el promedio se ha calculado\n");
        if (codecPoint == SIZE_BUFFER) //SIZE_BUFFER
        {
        LOG_printf(&trace, "el valor de codecPoint es %d\n", codecPoint);
        }        
}


void eventMcBSP0() /The ISR
{
   
    buffPtr_First[firstPoint] = MCBSP_DRR_32BIT;
    firstPoint++;
  
   
    if (firstPoint == rate)
        {
        LOG_printf(&trace, "se lleno el buffer\n");
        SEM_postBinary(&SEM0);
        flag=1;
        }  
}

Could you help me?

Best regards.

Manuel Fernández Ros

  • Manuel,

    The GIE bit is set after main() and before tasking begins. It should be set when the task function is entered.

    Can you show me the .tcf code you're using to set up HWI13?

    I believe it should look something like this:

    bios.HWI.instance("HWI_INT13").interruptSelectNumber = 40;
    bios.HWI.instance("HWI_INT13").useDispatcher = 1;
    bios.HWI.instance("HWI_INT13").fxn = prog.extern("eventMcBSP0");

    Alan

  • Hello Allan

    Yes, the tcf code is that. You can see the image..

    Regards.

    Manuel

     

  • I don' know much about McBSP but does your ISR have to acknowledge the interrupt somehow?

    Do you know if 'firstPoint' EVER gets incremented?

    Alan

  • Hello Alan

    I have a first program that works perfectly  but I don't use TSK, I have a 'while(1)'  loop inside 'main' and It is necesary to use  HWI_enable because never 'main' finishes. I have readed that it is not very correct, but it works.

     

    Now I should  like to use SEM and TSK, I think it is better but my surprise is that it doesn't work. The ISR only  works two times (or one). Is CSR.GIE disabled after activate SEM_pend?

    Best regards.

    Manuel.

  • BIOS occasionally disables global interrupts but ALWAYS re-enables them after completing its critical operations.

    Your ISR appears to only post SEM0 when 'firstPoint' == 'rate'. However firstPoint is incremented on every interrupt and 'rate' doesn't seem to be changing.

    So I think SEM0 will only get posted once. Which means that the task will only return from SEM_pend() once.

    Is this possible?

    Alan

  • 'rate' never changes. But 'firstPoint' is reset in 'taskProm', I hope that ISR catch the new value (firstPoint=0) in the next interrupts.

    Regards.

    Manuel

  • Ooos. I didn't see the "firstPoint = 0;" when I was studying the code initially. But I see it now...

    If the interrupt is happening more often than the task can service it, then firstPoint might creep past the size of the bufPtr_First[] array and result in memory corruption.

    Perhaps you can modify the ISR to only increment firstPoint up to the value of rate and not beyond:

    void eventMcBSP0() /The ISR

    {       

        if (firstPoint < rate) {

            buffPtr_First[firstPoint] = MCBSP_DRR_32BIT;
            firstPoint++;

        }  

       
        if (firstPoint == rate)  {
            LOG_printf(&trace, "se lleno el buffer\n");
            SEM_postBinary(&SEM0);
            flag=1;
        }  
    }

    Alan

  • Hello Alan

    Thank you for your response but it doesn't work. I have moved 'firstPoint = 0' to ISR and LOG the program and the result is this:

    - ISR is always working. It is GOOD.

    - The task 'taskProm' only works one time, and I don't know why.

    I have reduced a lot the code in 'taskProm' and the result is the same.

    Could you help me, please?

    Regards. Happy Christmas and Happy New Year.

    Manuel

  • Hello Alan

    Now, I have modified the program. The ISR is the same but I don't use TSK, I'm using SWI and it works perfectly.

    However, I'd like to know if there is some incompatibility with TSK and HWI (for future projects).

    Regards.

    Manuel

  • Manuel,

    Your usage of SEM_post() within a HWI to wake up a task pending on the SEM is VERY NORMAL and should work as expected.

    I'm wondering if the stack configured for the task is too small and consequently getting overrun when the interrupt occurs.

    Can you try increasing the task stack size and see if the problem clears up?

    Alan