This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1350: Modifying the wakeup on radio example

Genius 13859 points
Part Number: CC1350

Hi Experts,

Good day. Trying to ask assistance here as I client would like to modify the wakeup on radio example so that it contains the example for the pin interrupt ( ADC & digital pin) and the ADC single conversion example, below is is code.

I already advised him  to look at the "pinInterrupt" example and how it works and start working by calling it with a simple function to confirm its operation before implementing with their intended application; but refused.

Can you advise more on this?

Thank you very much.

Regards,
Archie A.

PIN_Config buttonPinTable[] = { Board_DIO22 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES, Board_ADC0 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES, Board_DIO21 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES, PIN_TERMINATE }; uint32_t ConvertAdct0MicroVolt() { ADC_Handle adc; ADC_Params params; uint32_t val; ADC_init(); ADC_Params_init(&params); adc = ADC_open(Board_ADC0, &params); if (adc == NULL) { while (1); } int i=0; for(i=0;i<100;i++) { /* Blocking mode conversion */ int_fast16_t res; uint16_t adcValue0; res = ADC_convert(adc, &adcValue0); if (res == ADC_STATUS_SUCCESS) { val = val + ADC_convertRawToMicroVolts(adc, adcValue0); val = val/100; } else { } } ADC_close(adc); return (val); } /***** Function definitions *****/ /* Pin interrupt Callback function board buttons configured in the pinTable. */ void buttonCallbackFunction(PIN_Handle handle, PIN_Id pinId) { CPUdelay(8000*50); if (!PIN_getInputValue(pinId)) { /* Toggle LED based on the button pressed */ switch (pinId) { case Board_DIO21: flag=1; break; case Board_DIO22: flag=2; break; case Board_ADC0: if (!PIN_getInputValue(pinId)&& (flag==1)) { /* Post TX semaphore to TX task */ Semaphore_post(txSemaphoreHandle); } else if(!PIN_getInputValue(pinId)&& (flag==2)) { PIN_setOutputValue(ledPinHandle, Board_DIO12,1); int i; for(i = 0; i<steps_per_rev; i++) { PIN_setOutputValue(ledPinHandle, Board_DIO15,1); CPUstatic

void txTaskFunction(UArg arg0, UArg arg1) { /* Initialize the display and try to open both UART and LCD types of display. */ Display_Params params; Display_Params_init(&params); params.lineClearMode = DISPLAY_CLEAR_BOTH; Display_Handle uartDisplayHandle = Display_open(Display_Type_UART, &params); Display_Handle lcdDisplayHandle = Display_open(Display_Type_LCD, &params); /* Print initial display content on both UART and any LCD present */ Display_printf(uartDisplayHandle, 0, 0, "Wake-on-Radio TX"); Display_printf(uartDisplayHandle, 0, 0, "Pkts sent: %u", seqNumber); Display_printf(lcdDisplayHandle, 0, 0, "Wake-on-Radio TX"); Display_printf(lcdDisplayHandle, 1, 0, "Pkts sent: %u", seqNumber); /* Setup callback for button pins */ PIN_Status status = PIN_registerIntCb(buttonPinHandle, &buttonCallbackFunction); Assert_isTrue((status == PIN_SUCCESS), NULL); /* Initialize the radio */ RF_Params rfParams; RF_Params_init(&rfParams); /* Initialize TX_ADV command from TX command */ initializeTxAdvCmdFromTxCmd(&RF_cmdPropTxAdv, &RF_cmdPropTx); /* Set application specific fields */ RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH +1; /* +1 for length byte */ RF_cmdPropTxAdv.pPkt = packet; RF_cmdPropTxAdv.preTrigger.triggerType = TRIG_REL_START; RF_cmdPropTxAdv.preTime = WOR_PREAMBLE_TIME_RAT_TICKS(WOR_WAKEUPS_PER_SECOND); /* Request access to the radio */ #if defined(DeviceFamily_CC26X0R2) rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams); #else rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); #endif// DeviceFamily_CC26X0R2 /* Set the frequency */ RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0); /* Enter main TX loop */ while(1) { adcVal = ConvertAdct0MicroVolt(); /* Wait for a button press */ Semaphore_pend(txSemaphoreHandle, BIOS_WAIT_FOREVER); /* Create packet with incrementing sequence number and random payload */ packet[0] = PAYLOAD_LENGTH; packet[1] = (uint8_t)(seqNumber >> 8); packet[2] = (uint8_t)(seqNumber++); uint8_t i; for (i = 3; i < PAYLOAD_LENGTH +1; i++) { packet[i] = rand(); } /* Send packet */ RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0); /* Update display */ Display_printf(uartDisplayHandle, 0, 0, "Pkts sent: %u", seqNumber); Display_printf(lcdDisplayHandle, 1, 0, "Pkts sent: %u", seqNumber); /* Toggle LED */ PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1)); } } delay(80 * 8000); PIN_setOutputValue(ledPinHandle, Board_DIO15,0); CPUdelay(80 * 8000); } } else { } break; default: /* Do nothing */ break; } } } ;

  • Hi Archie,

    Could you please reformat the code in your question to be readable, like that we'll be able to help you. You can do that by clicking Insert->Code or Formats->formats->Inline->Code to create a code block inside of your post. Alternatively you can add it as a separate file with Insert->Image/Video/File.

    Regards,

    Fausto