Part Number:CC2642R
Tool/software: TI-RTOS
Hello,
We have been looking into issues regarding current consumption on the SPI micro-SD card interface on custom boards that were upgraded to the CC2642R1 (Rev E. Silicon – SDK 3.10.0.53) from the CC2640. With the new CC2642R1 hardware and associated TI software upgrades, we consistently see system current of approximately 18.5 mA whereas on the older CC2640 boards the current was approximately 1.5 mA. These currents were measured on multiple CC2642R1 and multiple CC2640 boards all with the same micro-SD card.
Under a hypothesis that the high current consumption was related to the f_writes, which occur every 900 ms, a simple program for the CC2642R1 board was developed to see if any changes in current consumption could be noted when the f_writes were replaced with no-ops. The program consisted of a call to the SDFatFs driver for initialization, then an f_open followed by a no-op every 900 ms. We verified none of MISO, MOSI, and SCLK lines were active after the f_open. Using an inline ammeter I measured a system runtime current consumption of 18.5 mA. I concluded that that high current was not due to the f_write operations.
The next hypothesis was that there is an issue with the FATfs initialization process, since it was verified through the use of a scope that no micro-SD card activity was occurring following FATfs initialization.
Keeping the same program on the CC2642R1 board, I then stepped through the code with the in-line ammeter attached during the debugging session to see where in the code the current increased from approximately 0.3 mA to 18.5 mA. During the debugging session I found that the increase in current occurred following a call to f_open and remained at 18.5 mA even when the file was closed. Digging deeper into the f_open call, I found that the increase in current occurred at the end of the first iteration of the following code snippet from SDPI.c:
do {
/* ACMD41 with HCS bit */
if ((sendCmd(object->spiHandle, CMD55, 0) <= 1) &&
(sendCmd(object->spiHandle, CMD41, 1UL << 30) == 0)) {
status = SD_STATUS_SUCCESS;
break;
}
currentTime = ClockP_getSystemTicks();
} while ((currentTime - startTime) < timeout);
Having measured total system current up to this point, I needed to isolate exactly where the current consumption was coming from. To do this, the ammeter was connected between the VCC supply and the VCC pin of the micro-SD card’s interface. After initializing the FATfs and applying power to the micro-SD’s VCC pin, the current was measured at 0.3 mA. Following the call to f_open, a current of 18.23 mA was measured.
At this point I was convinced that the high current was related to an interaction between the f_open function and the micro-SD card. Since the micro-SD card interface was identical on my CC2640 and CC2642R1 boards, I thought it unlikely that the high current was due to my custom hardware, but ran the test below to test this assumption.
To determine if the high current consumption by the micro-SD card was independent of my hardware, I tested on a TI CC2642R1 LaunchPad (Rev C silicon) with an Adafruit micro-SD card breakout board attached. As with the custom CC2642R1 boards, the micro-SD card current through the VCC pin jumped from 0.2 mA to a constant 18.82 mA following the call to f_open. This block diagram of how the current measurement was obtained along with the code used is shown below:
![]()
/*
* ======== main.c ========
*/
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include <file.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
#include <ti/drivers/I2C.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>
#include "ti/drivers/SDFatFS.h"
#include "third_party/fatfs/ff.h"
#include <third_party/fatfs/diskio.h>
#include "C:\ti\simplelink_cc2640r2_sdk_2_30_00_28\source\third_party\fatfs\ff.c"
#include "Board.h"
/*
*
* Pin setup for CC2642R1 (rev C silicon) LaunchPad to Adafruit Micro SD card module
*
* --- Launch Pad pin --- --- Micro SD pin ---
* 3.3 v 3.0 v // VCC
* GND GND // GND
* DIO10 CLK // SCLK
* DIO8 DO // MISO
* DIO9 DI // MOSI
* DIO21 CS // SD CS
*
*/
SDFatFS_Object myObj;
SDFatFS_Config SDFatFS_config[] =
{
{ &myObj },
NULL
};
uint_least8_t SDFatFS_count = sizeof(SDFatFS_config) / sizeof(SDFatFS_config[0]) - 1;
/* Set this to the current UNIX time in seconds */
const struct timespec ts = {
.tv_sec = 1469647026,
.tv_nsec = 0
};
int32_t fatfs_getFatTime(void)
{
time_t seconds;
uint32_t fatTime;
struct tm *pTime;
seconds = time(NULL);
pTime = localtime(&seconds);
fatTime = ((uint32_t)(pTime->tm_year - 80) << 25) |
((uint32_t)(pTime->tm_mon) << 21) |
((uint32_t)(pTime->tm_mday) << 16) |
((uint32_t)(pTime->tm_hour) << 11) |
((uint32_t)(pTime->tm_min) << 5) |
((uint32_t)(pTime->tm_sec) >> 1);
return ((int32_t)fatTime);
}
FATFS fs[2]; /* Work area (filesystem object) for logical drives */
FIL fsrc, fdst; /* File objects */
BYTE buffer[4096]; /* File copy buffer */
FRESULT fr; /* FatFs function common result code */
UINT br, bw; /* File read/write count */
BYTE workarea[4096]; /* Work area */
void mainThread()
{
SDFatFS_Handle sd_handle;
SDFatFS_init();
sd_handle = SDFatFS_open(Board_SD0,0);
if (sd_handle == NULL) {
//Error opening SDFatFS driver
while (1);
}
/* Open source file, handle errors */
fr = f_open(&fsrc, "myfile", FA_OPEN_EXISTING | FA_WRITE);
switch (fr)
{
case FR_NO_FILE:
fr = f_open(&fsrc, "myfile", FA_CREATE_NEW | FA_WRITE);
System_printf("fr after f_open: %d \n",fr);System_flush();
default:
break;
}
if(fr != 0)
while(1);
/* Write to file, sync, sleep, read, print, repeat ... */
uint8_t counter = 0;
char buffer [100];
int cx;
while (counter <= 100)
{
/* Write count as string to file ... */
cx = snprintf (buffer, 100, "Count is: %d \r\n", counter);
System_printf("current count: %d\n",counter);System_flush();
fr = f_write(&fsrc, buffer, cx, &bw);
if(fr != 0)
while(1);
/* Try to sync */
fr = f_sync(&fsrc);
if(fr != 0)
while(1);
/* Delay */
CPUdelay(8000 * (1000));
counter++;
}
/* Close open files */
f_close(&fsrc);
while(1)
CPUdelay(8000 * (1000));
}
/*
* ======== main ========
*/
int main()
{
/* Call driver init functions */
Board_initGeneral();
I2C_init();
SPI_init();
UART_init();
// Declare task param structure and task handle
Task_Params taskParams;
Task_Handle sampleSensors;
Error_Block eb;
Error_init(&eb);
/* Create 1 task with priority 1 */
Task_Params_init(&taskParams);
taskParams.stackSize = 2048;
taskParams.priority = 1;
sampleSensors = Task_create((Task_FuncPtr)mainThread, &taskParams, &eb);
if (sampleSensors == NULL) {
System_abort("Task create failed");
}
//call BIOS_start() enables interrupts and starts the scheduler with BIOS
BIOS_start();
return (0);
}
/*
* Copyright (c) 2015-2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Given that the high current consumption by a micro-SD card discovered on my CC2642R1 custom boards and is also present when using the TI CC2642R1 LaunchPad, I am concerned there is a problem with the TI-supplied software. Could it be that there is a driver issue where during the f_open call something occurs that does not allow the micro-SD card to return to a normal power state? Was current consumption measured as part of software verification for the current RTOS/FATfs/SDK/CC2642R1 hardware?
To meet our system runtime requirements, we need to return to the 1.5 mA average current. We are hopeful that someone at TI can repeat our tests run on the CC2642R1 LaunchPad and develop a solution.
Thanks,
- Stephen Poanessa