data capture via UART after LLS wakeup in Kinetis mqx

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

data capture via UART after LLS wakeup in Kinetis mqx

1,201 次查看
annamol
Contributor IV

Hi,

 I am trying to configure K65 in LLS with uart wakeup.

To achieve the same the following changes were made.

In user_Config.h,

   #define BSPCFG_ENABLE_ITTYC      1

and in  init_lpm.c

{

        LPM_CPU_POWER_MODE_LLS,                     // Index of predefined mode
        0,                                          // Additional mode flags
        0,                        

        LLWU_PE2_WUPE4(3)|LLWU_PE2_WUPE5(3)||LLWU_PE2_WUPE7(3),  
        LLWU_PE3_WUPE8(3),                                          // Mode wake up events from pins 8..11
        LLWU_PE4_WUPE12(3)|LLWU_PE4_WUPE13(3),                                            
        LLWU_ME_WUME0_MASK|LLWU_ME_WUME5_MASK     
    },.

In init_Sci.c,  // to enable serial line in stop mode

/* LPM_OPERATION_MODE_STOP */
    {
        IO_PERIPHERAL_PIN_MUX_ENABLE | IO_PERIPHERAL_CLOCK_ENABLE,
        0,
        0,
        0
    },

These changes were made. I can wake up via UART interrupt from LLS. At times, the event bit which i set after waking up doesn't get set and uart doesn't receive any data. Since debugger gets disconnected in LLS, can't make out exactly what is happening. I have mapped a new uart_isr with the intention of capturing data received via UART to kick start another task. 

 

It would be great if someone can point me where I am going wrong in capturing data from UART.

  • Is it possible to keep debugger enabled in LLS mode??
  • How can I capture data from UART while waking from LLS? Is my implementation wrong

 

 

Thanks for the support

Original Attachment has been moved to: uart_lls.c.zip

0 项奖励
回复
4 回复数

916 次查看
mjbcswitzerland
Specialist V

Hi

See
Low power with UARTs: https://community.freescale.com/message/421247#421247

LLS has a fairly long time delay from the UART start edge detection wake up and operation so the UART needs to be quite slow for it to be able to work. VLPS can work up to about 56kBaud.

Debugging in LLS is NOT possible.

Regards

Mark

0 项奖励
回复

916 次查看
annamol
Contributor IV

Hi,

Thanks for the valuable docs. I will try with VLPS mode for uart data capture. Between is this approach OK for capturing data via UART after wake up.

Correct me if I am doing something wrong.

#include <mqx.h>

#include <bsp.h>
#include <fio.h>
#include <lwevent.h>


/* Task IDs */
#define HELLO_TASK 5
#define UART_TASK 6

 /* LW Event Definitions */
  LWEVENT_STRUCT lwevent;

extern void hello_task(uint32_t);
void uart_task(uint32_t);
MQX_FILE_PTR uart;
//char data[5];
const TASK_TEMPLATE_STRUCT  MQX_template_list[] =
{
    /* Task Index,   Function,   Stack,  Priority, Name,     Attributes,          Param, Time Slice */
    { HELLO_TASK,   hello_task, 1500,   8,        "hello",  MQX_AUTO_START_TASK, 0,     0 },
    {UART_TASK,uart_task,1500,8,"uart",MQX_AUTO_START_TASK,0,0},
    { 0 }
};
#define UART_EVENT  0x01

/* Function name:uart_task
*  Description  :to receive data through UART
*/
char data[5];
char *data_ptr=data;
int received;
void uart_task(uint32_t initial_data)
{                               // variable to store received character
   
  UART_MemMapPtr sci_ptr = _bsp_get_serial_base_address (2);
   while(1)
   {
     if(_lwevent_wait_ticks(&lwevent,UART_EVENT,TRUE,0) == MQX_OK)       // wait for UART event to be set when core wakes up from LLS
     {  
//       for(int k=0;k<3;k++)
//       {
//      fgets(received,sizeof(received),uart);
       *data_ptr = sci_ptr->D;        // D regsiter has data
       data_ptr++;
      if(strlen(data)==4)
      {
        if(strncmp(data,"spo2",4)==0)
          _io_set_handle(IO_STDOUT,uart);
        printf("%s",data);
        data_ptr-=4;
        memset(data,0x00,sizeof(data));
      }
//       printf("\n%c",data[received++]);
       _lwevent_clear(&lwevent,UART_EVENT);
      
     }
   }
 }
/* Function name:uart_isr
*  Description  :isr to enable uart event mask for data parsing
*/
void uart_isr()
{
  char received;                        // variable to store received character
   
  UART_MemMapPtr sci_ptr = _bsp_get_serial_base_address (2);
   received = sci_ptr->S1;       // Read status register to clear off the interrupt flag
   received = sci_ptr->D;        // D regsiter has data
   _lwevent_set (&lwevent, UART_EVENT);
 
}

void hello_task    ( uint32_t initial_data )
{
    (void)initial_data; /* disable 'unused variable' warning */    
    printf("Hello World\n");
    
    /*Create event for task synchronization*/
     if (_lwevent_create(&lwevent,0) != MQX_OK)
     {
        printf("\n event creation failed");
     }    
     
    for(int k=0;k<100000;k++);
    
    uart=fopen("ittyc:",NULL); //(const char*)(IO_SERIAL_NON_BLOCKING|IO_SERIAL_RAW_IO)
    if(uart ==NULL)
      printf("\n uart opening failed");
    _int_install_isr(INT_UART2_RX_TX, (INT_ISR_FPTR)uart_isr, uart);
    _bsp_int_init(INT_UART2_RX_TX,2,0,TRUE);
     for(int k=0;k<10000;k++);

    _task_block();
}

0 项奖励
回复

916 次查看
soledad
NXP Employee
NXP Employee

Hi,

Please check the below application note. This application describes the MQX LPM, how it works, and how to use it. Specifically, it references the Kinetis K60 family and the Tower TWR-K60N512 development board and Board Support Package (BSP). However, other MCUs and boards are supported by the LPM.

http://www.nxp.com/assets/documents/data/en/application-notes/AN4447.pdf 

I hope this helps, have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

916 次查看
mjbcswitzerland
Specialist V

Hi

I am sorry but I don't use MQX so you may need to contact the manufacturer or NXP for support

Regards

Mark

0 项奖励
回复