Part Number:LAUNCHXL-CC26X2R1
Tool/software: TI-RTOS
Hello TI Experts,
I am currently working on a project involving a CC26x2 chip integrated with an AFE4404, ADXL345, and a microSD card slot. This project is a continuation from a previous board which used the CC2640. The last build had some threading issues and I want to ensure that we avoid them in this new build. Here’s some background on how the device functions:
Sensor Controller Studio (SCS) collects 14 samples from the AFE4404 then a sample (x, y, z) from the ADXL345 through I2C set at 400 KHz. This process continues until an internal buffer in SCS generates an alert to wake the cc26x2 up and empty the SCS buffer. Task1 continuously checks for the SCS interrupt and when one is detected the outputted SCS buffer is received and then parsed into individual samples by task1. These samples are then sent to a ping-pong buffer by Task1. The general structure of this Task1 is shown below:
Initialize AFE, UART, I2C, SPI, ADXL345, microSD (FATFS), Pins, mem/buffers, and SCS.
Semaphore_Params semParams;
Semaphore_Params_init(&semParams);
Semaphore_construct(&semMainLoop, 0, &semParams);
hSemMainLoop = Semaphore_handle(&semMainLoop);
scifClearAlertIntSource();
while(1)
{
Check if time to sync
semaphore_pend(hSemMainLoop, BIOS_WAIT_FOREVER);
scifClearAlertIntSource();
Check SCS cfg variables to see how full SCS buffer is.
If cfg variable indicated full or almost full, the buffer is emptied.
ScifAckAlertEvents();
}
When one of the ping-pong buffer is approaching fullness, a semaphore is posted and Task2 is used to write the ping-pong buffer data to a microSD card through SPI. The general structure of Task 2 is shown below:
Semaphore_Params semParams2;
Semaphore_Params_init(&semParams2);
Semaphore_construct(&semWriteSD, 0, &semParams2);
hSemWriteSD = Semaphore_handle(&semWriteSD);
while(1)
{
Semaphore_pend(hSemWriteSD, BIOS_WAIT_FOREVER);
writeToSD();
}
Additionally, a periodic clock instance is started prior to the call to BIOS_Start(), and is triggered approximately every 11 seconds. When triggered, a variable is set to true, and during the next write of data to the SD card, an f_sync operation occurs.
Some questions:
1. Does this approach appear to be correct?
2. According to documentation, semaphores are by default counting. Is this a good setting for the tasks I have outlined?
3. Should there be priorities set for the semaphores mentioned? If so how would you go about determining which would be best for prioritization?
Thanks!
- Stephen