Hi team,
Here's an issue from the customer may need your help:
The customer would like to send data exactly once every 250us, the RTC CH2 channel is used for timing and then the radio is sent in the main program.
Issue:
a. RTC program test is OK, with GPIO level flipping, can be tested to around 250us.
b. The RF transmit test is ok and can be tested to the transmitted signal by the spectrum analyzer.
c. When the two are combined, the timer interrupt can enter normally, while RF transmission cannot operate.
Main program is as follows:
/*Timer interrupt handling function */
void RTCtimer_int_hanlder(uintptr_t arg)
{
GPIO_toggle(Board_GPIO_LED0);
send_flag = 1;
}
/*
* ======== adcThread ========
*/
void *adcThread(void *arg0)
{
ADC_Handle adc;
ADC_Params params;
/* Call driver init functions */
RTC_timerCreate(RTCtimer_int_hanlder);
GPIO_init();
ADC_init();
RF_tx_init();
ADC_Params_init(¶ms);
/*configure GPIO*/
GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
adc = ADC_open(Board_ADC0, ¶ms);
if (adc == NULL) {
while (1);
}
while(1)
{
/*ADC_convert(adc, &adcValue);*/
if(send_flag == 1)
{
send_flag = 0;
dataNumber++;
RF_tx_data(adcValue, dataNumber);
}
}
The timer program is as follows:
typedef struct _RTC_Obj {
RTC_Fxn tickFxn;
} RTC_Obj;
static HwiP_Struct RTC_hwiStruct;
static RTC_Obj RTC_handle;
static uint32_t delay_ticks = (uint32_t)(0.00025*FACTOR_SEC_TO_COMP_VAL_FORMAT); /*定时间隔*/
void RTC_init(void)
{
/*close and reset RTC*/
AONRTCDisable();
AONRTCReset();
HWREG(AON_RTC_BASE + AON_RTC_O_SYNC) = 1;
/* read sync register to complete reset */
HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
/*clear RTC event*/
AONRTCEventClear(AON_RTC_CH2);
IntPendClear(INT_AON_RTC_COMB);
HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
}
void RTC_intFxn(uintptr_t arg)
{
/* clear the RTC event */
AONRTCEventClear(AON_RTC_CH2);
RTC_handle.tickFxn(NULL);
}
void RTC_start(void)
{
uintptr_t key;
key = HwiP_disable();
/* reset timer */
AONRTCReset();
AONRTCEventClear(AON_RTC_CH2);
IntPendClear(INT_AON_RTC_COMB);
/*Sets the size of the comparison value */
AONRTCModeCh2Set(AON_RTC_MODE_CH2_CONTINUOUS);
AONRTCCompareValueSet(AON_RTC_CH2, delay_ticks);
AONRTCIncValueCh2Set(delay_ticks);
AONEventMcuWakeUpSet(AON_EVENT_MCU_WU0, AON_EVENT_RTC_CH2);
AONRTCChannelEnable(AON_RTC_CH2);
AONRTCCombinedEventConfig(AON_RTC_CH2);
AONRTCEnable();
/*Exit critical area */
HwiP_restore(key);
}
void RTC_timerCreate(RTC_Fxn timer_fxn)
{
uintptr_t hwiKey;
/*enter the critical area*/
hwiKey = HwiP_disable();
HwiP_Params hwiParams;
HwiP_Params_init(&hwiParams);
hwiParams.priority = INT_PRI_LEVEL4;
HwiP_construct(&RTC_hwiStruct, INT_AON_RTC_COMB, RTC_intFxn, &hwiParams);
RTC_init();
/*Exit critical area*/
HwiP_restore(hwiKey);
RTC_handle.tickFxn = timer_fxn;
RTC_start();
}
RF transmit is as follows:
void RF_tx_init(void)
{
RF_Params rfParams;
RF_Params_init(&rfParams);
if( RFQueue_defineQueue(&dataQueue,
txDataEntryBuffer,
sizeof(txDataEntryBuffer),
NUM_DATA_ENTRIES,
MAX_LENGTH + NUM_APPENDED_BYTES))
{
/* Failed to allocate space for all data entries */
while(true);
}
RF_cmdTxHS.pQueue = &dataQueue;
currentDataEntry = (rfc_dataEntryGeneral_t*)&txDataEntryBuffer;
currentDataEntry->length = PAYLOAD_LENGTH;
pPacket = ¤tDataEntry->data;
RF_cmdFs_preDef.frequency = 0x0364; //0x364:868Mhz, 0x0393: 915 MHz
RF_cmdFs_preDef.fractFreq = 0x0000;
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop_hsm, (RF_RadioSetup*)&RF_cmdRadioSetup_hsm, &rfParams);
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs_preDef, RF_PriorityNormal, NULL, 0);
}
void RF_tx_data(uint16_t playload, uint16_t seqNumber)
{
/* Create packet with incrementing sequence number and random payload */
pPacket[0]= (uint8_t)(seqNumber >> 8);
pPacket[1]= (uint8_t)(seqNumber++);
/* pPacket[2]= (uint8_t)(playload >> 8);
pPacket[3]= (uint8_t)(playload);*/
/* Send packet */
RF_EventMask terminationReason = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdTxHS,
RF_PriorityNormal, NULL, 0);
}
Could you help check this case? Thanks.
Best Regards,
Cherry