Other Parts Discussed in Thread: CC3200, UNIFLASH
Tool/software: Code Composer Studio
Hi,
I'm trying to activate LPDS mode but I don't get it. I'm measuring the current and I see 17mA and the launchpad don't enter in LPDS mode.
I have seen the example idle_profile but I don't get it. Can you tell me if something is missing?
I've made a simple example that it has a timer of 10secs that toggle a LED. The code is this:
In the Main.c file:
//*****************************************************************************
// MAIN FUNCTION
//*****************************************************************************
void main()
{
long lRetVal = -1;
unsigned char QueueMsg = 0;
QueueMsg = 0;
// Board Initialization
BoardInit();
// configure the GPIO pins for LEDs,UART
PinMuxConfig();
// Initialize the platform
pm_framework_init();
// configure LEDs
GPIO_IF_LedConfigure(LED1|LED2|LED3); //Orange, Red
GPIO_IF_LedOff(MCU_ALL_LED_IND);
// Configure the UART
g_tUartHndl = uart_open(PRCM_UARTA0);
//// Display Application Banner
DisplayBanner(APPLICATION_NAME);
// Start the SimpleLink Host
lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
LOOP_FOREVER();
}
// sync object for inter thread communication
lRetVal = osi_MsgQCreate(&qMain, "Main_Queue", sizeof( unsigned char ),3);
if(lRetVal < 0)
{
Report("could not create Main queue\n\r");
LOOP_FOREVER();
}
// sync object for inter thread communication
lRetVal = osi_MsgQCreate(&qWifi, "WIFI_Queue", sizeof( unsigned char ),6);
if(lRetVal < 0)
{
Report("could not create queue Wifi\n\r");
LOOP_FOREVER();
}
// Start the TimerTask task
lRetVal = osi_TaskCreate(MainTask, (const signed char *)"Tarea Principal",
OSI_STACK_SIZE,NULL,2,NULL );
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
LOOP_FOREVER();
}
// Start the WlanStationMode task
lRetVal = osi_TaskCreate(WLAN_Connections_Task, (const signed char*)"Wlan Station Task", \
OSI_STACK_SIZE, NULL, 2, NULL );
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
LOOP_FOREVER();
}
// Start the task scheduler
osi_start();
LOOP_FOREVER();
}
//*****************************************************************************
void TimerCallback(void *vParam)
{
unsigned char ucQueueMsg = 1;
osi_MsgQWrite(&qMain, &ucQueueMsg, OSI_NO_WAIT);
return;
}
void MainTask(void *pvParameters)
{
unsigned char QueueMsg = 0;
Report("sTART MAIN Task\n\r");
QueueMsg = MSG_CONNECT_WIFI;
osi_MsgQWrite(&qWifi, &QueueMsg, OSI_NO_WAIT);
tTimerHndl = SetTimerAsWkUp();
lp3p0_setup_power_policy(POWER_POLICY_STANDBY);
cc_idle_task_pm();
while(1) {
// waits for the message from the TimerRTC
osi_MsgQRead(&qMain, &QueueMsg, OSI_WAIT_FOREVER);
switch(QueueMsg){
case MSG_TIMER:
GPIO_IF_LedToggle(MCU_RED_LED_GPIO);
break;
}
}
LOOP_FOREVER();
}
//*****************************************************************************
cc_hndl SetTimerAsWkUp()
{
cc_hndl tTimerHndl;
struct cc_timer_cfg sRealTimeTimer;
struct u64_time sInitTime, sIntervalTimer;
//
// setting up Timer as a wk up source and other timer configurations
//
sInitTime.secs = 0;
sInitTime.nsec = 0;
cc_rtc_set(&sInitTime);
sRealTimeTimer.source = HW_REALTIME_CLK;
sRealTimeTimer.timeout_cb = TimerCallback;
sRealTimeTimer.cb_param = NULL;
tTimerHndl = cc_timer_create(&sRealTimeTimer);
sIntervalTimer.secs = LPDS_DUR_SEC; //10 SECS
sIntervalTimer.nsec = LPDS_DUR_NSEC;
cc_timer_start(tTimerHndl, &sIntervalTimer, OPT_TIMER_PERIODIC);
return(tTimerHndl);
}
and the Wifi.c file:
void WLAN_Connections_Task(void *pvParameters)
{
int iSocketDesc, iRetVal;
long lRetVal = -1;
unsigned char QueueMsg = 0;
unsigned char i;
Report("Inicio Wlan Connection Task\n\r");
while(1) {
// waits for the message from the TimerRTC
osi_MsgQRead(&qWifi, &QueueMsg, OSI_WAIT_FOREVER);
switch(QueueMsg){
case MSG_CONNECT_WIFI:
Report("Iniciando Conexión WIFI.\n\r");
iRetVal = WLAN_Connection();
if (iRetVal < 0) {
// Close the socket
close(iSocketDesc);
UART_PRINT("Socket closed\n\r");
// Stop the driver
lRetVal = Network_IF_DeInitDriver();
if(lRetVal < 0)
{
UART_PRINT("Failed to stop SimpleLink Device\n\r");
}
}
break;
}
//
// Loop here
//
LOOP_FOREVER();
}
int WLAN_Connection() {
long lRetVal;
unsigned char policyVal;
unsigned char QueueMsg = 0;
// Reset The state of the machine
Network_IF_ResetMCUStateMachine();
// starting the simplelink
//
lRetVal = sl_Start(NULL, NULL, NULL);
if (lRetVal < 0)
{
UART_PRINT("Failed to start the device \n\r");
LOOP_FOREVER();
}
//
// Swtich to STA mode if device is not
//
SwitchToStaMode(lRetVal);
//
// Set the power management policy of NWP
//
lRetVal = sl_WlanPolicySet(SL_POLICY_PM, SL_NORMAL_POLICY, NULL, 0);
if (lRetVal < 0)
{
UART_PRINT("unable to configure network power policy\n\r");
LOOP_FOREVER();
}
// Initialize AP security params
SecurityParams.Key = (signed char *)passWifi;
SecurityParams.KeyLen = strlen(passWifi);
SecurityParams.Type = SECURITY_TYPE;
sl_WlanConnect((signed char *)SSID_NAME,strlen((const char *)SSID_NAME), 0, &SecurityParams, 0);
// Switch ON RED LED to indicate that Device acquired an IP
GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO);
return 1;
}
in the file lp3p0_board.c:
//****************************************************************************
int pm_framework_init(void) {
int retval = 0;
struct platform_pm_ops lp3p0_pm_ops;
struct cc_timer_setup timer_setup;
struct cc_dma_cfg dma_config;
tROMVersion* pRomVersion = (tROMVersion *)(ROM_VERSION_ADDR);
u32 *spi_baud_rate;
/* Initialize the PM framework */
retval = cc_pm_framework_init();
/* Get the SOC specific platform operations */
lp3p0_get_pm_ops(&lp3p0_pm_ops);
/* Register PM ops with framework */
if(cc_pm_platform_ops_register(&lp3p0_pm_ops)){
Report("Error: PM framework init failed");
while(1);
}
/* Register the power management ISR */
register_isr(INT_PRCM, prcm_interrupt_handler, NULL);
/* Register the timer ISR */
register_isr(INT_TIMERA2A, timer_interrupt_handler, NULL);
// Initialize the platform specific services
timer_setup.enbl_irqc = osi_ExitCritical;
timer_setup.dsbl_irqc = osi_EnterCritical;
retval = cc_timer_module_init(&timer_setup);
// Initialize RTC services
retval = rtc_module_init();
/* Initialize timer services */
MAP_PRCMPeripheralClkEnable(PRCM_TIMERA2, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
/* Initialize GPIO services */
retval = gpio_module_init(&gpio_list[0], (sizeof(gpio_list)/sizeof(int)));
// Initialize the DMA module
MAP_PRCMPeripheralClkEnable(PRCM_UDMA, PRCM_RUN_MODE_CLK|
PRCM_SLP_MODE_CLK);
dma_config.ctl_table = dma_ctrl_table;
retval = cc_dma_init(&dma_config);
spi_baud_rate = &(((struct cc_spi_config*)(modules[0].hw_detail))->baud_rate);
//* deciding the SPI baud rate depending upon PG version
if(pRomVersion->ucMinorVerNum == ROM_VER_PG1_21 )
{
*spi_baud_rate = SPI_RATE_13M;
}
else if(pRomVersion->ucMinorVerNum == ROM_VER_PG1_32)
{
*spi_baud_rate = SPI_RATE_13M;
}
else if(pRomVersion->ucMinorVerNum >= ROM_VER_PG1_33)
{
*spi_baud_rate = SPI_RATE_20M;
}
// Load the application specific modules
#if 1
#define NUM_SOC_MODULES(modules) (sizeof(modules) / sizeof(struct soc_module))
if(-1 == cc_modules_load(modules, NUM_SOC_MODULES(modules))) {
//* Should modules be unloaded?
retval = -1;
}
#endif
return retval;
}
//****************************************************************************
void prcm_interrupt_handler(void *intr_param)
{
int status;
/* Read the interrupt status, also clears the status */
status = MAP_PRCMIntStatus();
if((PRCM_INT_SLOW_CLK_CTR == status) || (sw_simulate_rtc)) {
sw_simulate_rtc = 0;
/* Invoke the RTC interrupt handler */
cc_rtc_isr();
} else if(0 == status) {
/* Invoke the wake from LPDS interrupt handler */
wake_interrupt_handler();
} else {
}
}
void timer_interrupt_handler(void *intr_param)
{
sw_simulate_timer = 0;
cc_hwt32_isr(timer_hndl);
}
THANKS.