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.
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; }
Hello Egor,
1. Pinmux-->Special pinmuxing: Use Alternate ADC 'Trigger Option-B' and Enable TBCLK sync
What is your event selected to generate ePWM interrupt?
Can you enable the adc interrupt and read the ADC data in the ADC ISR?
For example:
adcEnableNotification(adcREG1, adcGROUP0);
adcStartConversion(adcREG1, adcGROUP0);
/* USER CODE BEGIN (4) */
void adcNotification(adcBASE_t *adc, uint32 group)
{
adcData_t data;
uint32 count;
uint16 cmpA;
count = adcGetData(adcREG1, adcGROUP0, &data);
}
Hello, QJ Wang!
After the execution of your instructions, nothing happened.
The event is CTR_PRD of ETPWM1 module. I tried use CMPA but there is no effect.
It is not possible to use the ADC interrupt for its startup, as ADC interrupts will spoil the CPU. The specificity of the software being developed assumes that the ADC operates maximally independently of the processor.
Thanks!
I launch it, somehow... If i choose ETPWMA2 it works. Apparently, the problem in PINMMR registers.
What the datasheet says:
For triggering by ETPWMA2:
G1SRC = 110;
PINMMR30[0] = 0;
PINMMR30[1] = 1;
and what we have after halcogen:
G1SRC = 110;
PINMMR30[0] = 0;
PINMMR30[1] = 0;(!)
It is strange. But it something work.
For triggering by ETPWMA1:
G1SRC = 011;
PINMMR30[0] = 0;
PINMMR30[1] = 1;
PINMMR30[16] = 0;
PINMMR30[17] = 1;
after halcogen:
G1SRC = 011;
PINMMR30[0] = 0;
PINMMR30[1] = 0;(!)
PINMMR30[16] = 0;
PINMMR30[17] = 1;
end it does not work.
Is there a field in the halcogen determining mux, shown in the second figure?
I found a bug. I did not take into account SOCxA_SEL registers. PINMMR35 register must be set manually. All work. But why it works without PINMMR[30] = 1 unclear.