Hi,
The following code is works well in debug remote mode.
But When I plugged out the usb port of launchpad(standalone mode) It does not working at event_pend().
I used default environment and example(sensor node network configuration) and only check the timer.
Thanks.
Void tickFxn(UArg arg0)
{
// Timer_getFreq(timer1, freq);
static UInt16 toggle = 0;
toggle++;
if((toggle % 10) == 0){
PIN_setOutputValue(ledPinHandle, Board_LED3,!PIN_getOutputValue(Board_LED3));
/* Save latest value */
latestAdcValue = (uint16_t)rand();
//latestAdcValue = toggle;
/* Post event */
Event_post(nodeEventHandle, NODE_EVENT_NEW_ADC_VALUE);
// System_printf("myIsr arg = %d\n", (Int)arg0);
}
}
static void nodeTaskFunction(UArg arg0, UArg arg1)
{
/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, pinTable);
if(!ledPinHandle) {
System_abort("Error initializing board 3.3V domain pins\n");
}
#if 1
Timer_Params timerParams;
Timer_Handle myTimer;
Error_Block eb;
Error_init(&eb);
#else
/* Start the SCE ADC task with 1s sample period and reacting to change in ADC value.
* A change mask of 0xFF0 means that changes in the lower 4 bits does not trigger a wakeup.*/
SceAdc_init(0x00010000, 0xFF0);
SceAdc_registerAdcCallback(adcCallback);
SceAdc_start();
#endif
#ifdef YTS
char buf[8];
UART_Handle uart;
UART_Params uartParams;
const char echoPrompt[] = "\fStart cc1310...\r\n";
/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 9600;
uartParams.dataLength = UART_LEN_8;
uartParams.stopBits = UART_STOP_ONE;
uartParams.parityType = UART_PAR_NONE;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL) {
System_abort("Error opening the UART");
}
UART_write(uart, echoPrompt, sizeof(echoPrompt));
Timer_Params_init(&timerParams);
//timerParams.extFreq.lo = 24000000; //Timer Frequency
//timerParams.extFreq.hi = 0;
timerParams.runMode = Timer_RunMode_CONTINUOUS; //periodic timer
timerParams.startMode = Timer_StartMode_AUTO;
timerParams.periodType = Timer_PeriodType_MICROSECS;
timerParams.period = 100000; //100msec
timerParams.arg = 1;
myTimer = Timer_create(Timer_ANY, tickFxn, &timerParams, &eb);
if (myTimer == NULL) {
System_abort("Timer create failed");
}
Timer_start(myTimer);
PIN_setOutputValue(ledPinHandle, Board_LED3, 1);
#endif
while(1) {
/* Wait for event */
uint32_t events = Event_pend(nodeEventHandle, 0, NODE_EVENT_ALL, BIOS_WAIT_FOREVER);
//Here hang in or halted????
/* If new ADC value, send this data */
if(events & NODE_EVENT_NEW_ADC_VALUE) {
/* Toggle activity LED */
PIN_setOutputValue(ledPinHandle, NODE_ACTIVITY_LED,!PIN_getOutputValue(NODE_ACTIVITY_LED));
/* Send ADC value to concentrator */
NodeRadioTask_sendAdcData(latestAdcValue);
sprintf(buf, "0x%04x\r\n", latestAdcValue);
UART_write(uart, buf, sizeof(buf));
}
}
}