AnsweredAssumed Answered

How to configure SDADC data valid output as input of ETPU

Question asked by Thanh Nguyen on Mar 20, 2019
Latest reply on Apr 18, 2019 by David Tosenovjan

Hello NXP talents,

 

I'm working with SDADC and ETPU modules of MPC5777C MCU. I have created my application based on the examples: Example MPC5777C-eTPU_GPIO_test GHS714  , Example MPC5777C-SDADC_simple GHS614 .

In my application, the SDADC_2 data valid event output is configured as input of ETPUB channel 10. I expect the util_etpu_gpio_pin_history() function will return 1 when the Data Valid Flag is 1, but the util_etpu_gpio_pin_history() function always return 0.

The below is my code:

 

void SDADC2_Init(void)
{

/* Divider 64 for SD_CLK (max 16MHz, min 4MHz) i.e.264/64 = 4.125MHz */
SIU.SDCLKCFG.R = 0x0000003F;
/* enable SDADC in the single-ended mode */
SDADC_2.MCR.R = 0x00000003;
/* INP (positive terminal) = AN[0]
INM (negative terminal) = VREFN */
SDADC_2.CSR.R = 0x0;
/* set output settling delay to max */
SDADC_2.OSDR.R = 0xFF;
/* FIFO 16 words deep, enabled */
SDADC_2.FCR.R = 0x107;
/* Enable data valid event output */
SDADC_2.RSER.R = 0x00000004;
/* send key to reset ADC to start sampling */
SDADC_2.RKR.R = 0x5AF0;
}

 

void main (void)
{
vint32_t counter = 0;
vint32_t error_code;
vuint32_t dataValidFlag = 0;

HW_init();
Interrupts_init();
Interrupts_enable_Core0();

/* initialize pad */
SIU.PCR[ETPUB10_pin].R = (ALT1 | IBE | WPE | WPS) ;
/* Config the SDADC_2 data valid output is input of ETPUB channel 10 */
SIU.SDETPUB.B.CH10 = 1;

/* initialize ICF filter, otherwise input does not pass to the module */
IGF_1.FILTER[27].MCR.B.FGEN = 1;

/* initialize eTPU hardware */
fs_etpu_init (my_etpu_config, (uint32_t *) etpu_code, sizeof (etpu_code),
(uint32_t *) etpu_globals, sizeof (etpu_globals));

/* initialize eTPU channels */
error_code = fs_etpu_gpio_init (GPIO10_B, FS_ETPU_PRIORITY_MIDDLE);

/* enable all timebases */
fs_timer_start ();
/* Init SDADC_2 */
SDADC2_Init();
/* waiting for data valid flag is set */
while(((dataValidFlag == 0)))
{
validDataFlag = SDADC_2.SFR.R & 0x4;
}
Delay(1000);

fs_etpu_gpio_input_immed(GPIO10_B);
pinstate = util_etpu_gpio_pin_history(GPIO10_B);

while(1);

}

 

May I have something wrong, could you help me to check it?

 

Thanks and regards,

Thanh.

Outcomes