Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 216576

Forum Post: TMS320F28377D: Can't get EPWM_setADCTriggerEventCountInitValue() library function to work for any initial value other than one

$
0
0
Part Number: TMS320F28377D I have 3 ADC sequences programmed and I'm trying to stagger the SOCs using the library function EPWM_setADCTriggerEventCountInitValue() in TI's C2000 code, file epwm.h. My PWM is 20KHz and I'm trying to sample at 5KHz but staggered. My understanding of the initial value and prescalar is that I could set all the SOC prescalars to 4 to get 1 SOC every 4 PWMs (5KHz) and that I could give each of them a different initial value (1, 2, 3) in order to see them count like this epwm1 SOCB 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4... epwm4 SOCB 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1... epwm7 SOCB 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2... Since I don't have an example to use, I put together the sequence of register initializations myself. The code below does not work as expected - I only get a working 1 every 4 SOC on EPWM1 SOCB (initial value 1). I get nothing on EPWM4 (initial value 2), as if the counter was initialized to zero, and I get 1 every 2 SOC on EPWM7 (initial value 3), as if the counter re-initializes to 3 every SOC (e.g. 3, 4, 3, 4, 3, 4, 3, 4...). I am hoping that I've just missed something in the register initialization? The only way that I can get all 3 channels to generate a 1 every 4 SOC is to comment out the line that reads "EPWM_enableADCTriggerEventCountInit(epwm_base, EPWM_SOC_B); // added 10/7/2018", and when this is working, they are not staggered as desired. void EPWM_setupSOCs(uint32_t epwm_base) { uint16_t eventCountStaggerB = 0; // Disable SOCA & SOCB EPWM_disableADCTrigger(epwm_base, EPWM_SOC_A); EPWM_disableADCTrigger(epwm_base, EPWM_SOC_B); // Configure the SOCB on the period max count (peak at middle of on time for up-down counter) EPWM_setADCTriggerSource(epwm_base, EPWM_SOC_B, EPWM_SOC_TBCTR_PERIOD); EPWM_setADCTriggerEventPrescale(epwm_base, EPWM_SOC_B, 4); // was 1; seeing how this works if we only sample at 1/4 20KHz (5KHz) switch(epwm_base) { case EPWM1_BASE: eventCountStaggerB = 1; break; case EPWM4_BASE: eventCountStaggerB = 2; break; case EPWM7_BASE: eventCountStaggerB = 3; break; default: ASSERT(FALSE); break; } EPWM_enableADCTriggerEventCountInit(epwm_base, EPWM_SOC_B); // added 10/7/2018 EPWM_setADCTriggerEventCountInitValue(epwm_base, EPWM_SOC_B, eventCountStaggerB); EPWM_forceADCTriggerEventCountInit(epwm_base, EPWM_SOC_B); EPWM_enableADCTrigger(epwm_base, EPWM_SOC_B); }

Viewing all articles
Browse latest Browse all 216576

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>