Tool/software: TI-RTOS
Hello:
I use LAUNCHXL2-TMS57012 (TMS570LS1224). It’s needed to link the start of the ADC to the PWM. In HALKOGEN in the "Driver enable" tab I enable ADC and PWM drivers, configure and allow PWM to be the source of SOCA. In “Special pin muxing” set “Trigger option B” and then I set up the ADC. After I generate the code and flash the controller.
The program code is attached below. ADC does not work. The flag of completion of digitization is always equal 0. The flag of SOCA in the PWM module is generated.
How to fix it?
#include "sys_common.h" #include "gio.h" #include "adc.h" #include "reg_adc.h" #include "system.h" #include "etpwm.h" #include "sys_vim.h" #include "pinmux.h" #include "reg_pinmux.h" #include "sys_core.h" adcData_t adc_data[2] = {0,0}; uint32 adc_result[5] = {0,0,0,0,0}; int state = 0; void main(void) { adcInit(); adcStartConversion(adcREG1, adcGROUP1); muxInit(); etpwmInit(); etpwmStartTBCLK(); _enable_interrupt_(); while(1) { ; } } #pragma CODE_STATE(etpwm1Interrupt, 32) #pragma INTERRUPT(etpwm1Interrupt, IRQ) interrupt void etpwm1Interrupt(void) { asm ("_nop"); state = adcIsConversionComplete(adcREG1,adcGROUP1); adcGetData(adcREG1, adcGROUP1,&adc_data[0]); adc_result[adc_data[0].id] = adc_data[0].value; adc_result[adc_data[1].id] = adc_data[1].value; gioToggleBit(gioPORTB, 1); etpwmREG1->ETCLR = 1U; } #pragma CODE_STATE(etpwm2Interrupt, 32) #pragma INTERRUPT(etpwm2Interrupt, IRQ) interrupt void etpwm2Interrupt(void) { etpwmREG2->ETCLR = 1U; }