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.

RTOS/LAUNCHXL-CC2640R2: cc2640r2 Launchpad - using the Flash while Timer Interrupt registered

Part Number: LAUNCHXL-CC2640R2
Other Parts Discussed in Thread: BLE-STACK, SYSBIOS

Tool/software: TI-RTOS

Hi all,

I imported the simple_peripheral example for the cc2640r2 Launchpad and added a new Task.

In this Task I want to test the Flash on the Launchpad using the ExtFlash.c/h files from the oad_offchip example. I copied the two ExtFlash files to the Application folder of my project.

That works..

The moment I register a Timer Interrupt, the Flash test will hang at "SemaphoreP_pend(&(object->transferComplete)" [File: SPICC26XXDMA.c Funktion: SPICC26XXDMA_transfer (line 864)]

Here is my code:

#include "ExtFlash.h"
#include <driverlib/timer.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>

#define TASK_STACK_SIZE                 512
#define OWN_TASK_PRIORITY               1

Task_Struct task0Struct;
Char task0Stack[TASK_STACK_SIZE];


void timer0_ISR(void);
void own_Application_Task_Fxn(UArg arg0, UArg arg1);

void own_Application_Task_Init(void)
{
    Task_Params taskParams;

    /* Construct Task  thread */
    Task_Params_init(&taskParams);
    taskParams.stackSize = TASK_STACK_SIZE;
    taskParams.priority = OWN_TASK_PRIORITY;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)own_Application_Task_Fxn, &taskParams, NULL);
}

void timer0_ISR(void){

}

void own_Application_Task_Fxn(UArg arg0, UArg arg1)
{
    Power_setDependency(PowerCC26XX_PERIPH_GPT0);
    TimerDisable(GPT0_BASE, TIMER_A);

    TimerConfigure(GPT0_BASE, TIMER_CFG_PERIODIC_UP); 
    TimerLoadSet(GPT0_BASE, TIMER_A, 4800000);

    TimerStallControl(GPT0_BASE, TIMER_A, false);

    TimerIntRegister(GPT0_BASE, TIMER_A, timer0_ISR);
    TimerIntUnregister(GPT0_BASE, TIMER_A);

//  TimerIntClear(GPT0_BASE, TIMER_TIMA_TIMEOUT | TIMER_CAPA_MATCH | TIMER_CAPA_EVENT);
//  TimerIntEnable(GPT0_BASE, TIMER_TIMA_TIMEOUT);  

    Power_releaseDependency(PowerCC26XX_PERIPH_GPT0); 


    while(1)
    {
        ExtFlash_test();
        Task_sleep(30000);
    }
}

Even though I don't even use the Timer and immediately unregister the Timer Interrupt, it doesn't work... Without the registration of the Timer Interrupt, the Flash Test works as expected...

Any Idea, why? ;)

I forgot to mention: I'm using

-       CCS 7.2.0.00013

-       BLE-Stack 2.02.01.18

Thanks for your help,

Micha

 

  • Hi Micha,

    With the driverlib APIs you need to be careful. For example, you cannot use driverlib's *IntRegister apis because those are designed for a bare-metal system.
    I'd either look into using the Timer driver (ti/drivers/Timer.h) or the kernel's Timer module (ti/sysbios/knl/Timer.h).
  • Hi Tom,

    thanks for your answer! With the Timer driver I was able to Test the external Flash and read the device ID  with a Timer interrupt registered!

    But now I have another problem...

    I am able to erase a sector of the Flash and write to the Flash after that.

    But, I am only able to write up to 7 Bytes (what seems to quite random?). If I try to write 8 or more Bytes, it will wait for a Semaphore forever "SemaphoreP_pend(&(object->transferComplete)" [File: SPICC26XXDMA.c Funktion: SPICC26XXDMA_transfer (line 864)] - the same line as with the Timer problem.

    • I can write the 7 Bytes to different addresses an sectors.
    • I can write several 7 Bytes packages
    • If I use Task_sleep between 2 packages, it will also wait for the semaphore
    • If I write more than 7 Bytes, it will wait forever, but on the scope I can see, that all bytes are transmitted

    Here is my code (same Projekt as above):

    void own_Application_Task_Fxn(UArg arg0, UArg arg1)
    {
        bool status = 0;
        uint16_t address = 0;
        ExtFlashInfo_t *flashinfo = 0;
    
        uint8_t anz = 7;
        uint8_t writeBuf[256];
        uint8_t readBuf[256];
    
        ExtFlash_test();
        flashinfo = ExtFlash_info();
    
        status = ExtFlash_open();
    
        for(uint16_t i = 0; i < 256; ++i)
            writeBuf[i] = i;
    
    //    address = 1 << 12;
    
        status = ExtFlash_erase(address, 4096);
    
    //    ExtFlash_write(address, anz, writeBuf);
    //    Task_sleep(100);
    //    ExtFlash_write(address+6, anz, writeBuf+6);
        for(uint8_t i = 0; i < 30; ++i)
            ExtFlash_write((address+(i*anz)), anz, writeBuf+(i*anz));
    
    
    //    ExtFlash_read(address, 6, readBuf);
    //    ExtFlash_read(address+6, 6, readBuf+6);
        for(uint8_t i = 0; i < 30; ++i)
            ExtFlash_read(address+(i*anz), anz, readBuf+(i*anz));
    
        ExtFlash_close();
    
        while(1)
        {
            Task_sleep(1000);
        }
    }

     

    Any ideas, why I can't write more than 7 bytes with the API?

    Micha