Hi,
I have a F28335 control card plugged into a custom baseboard (it's driving a high power current source with some RS485/CAN/Zigbee interfaces on it)
I'm using the ePWM to start an 8-conversion sequential sample on the ADCs. It mostly works, but for some reason the highest bit in the result buffers isn't always set when it should be.
I call:
InitSysCtrl(); /// enables ADC clock
/// enables ADC clock again, loads ADC_cal and sets ADCTRL3.all to 0x00E0 (powers it up, no divider, sequential sampling mode)
InitAdc();
Initializes PWM:
// Setup Event Trigger
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable the ADC start of conversion A pulse
EPwm1Regs.ETSEL.bit.SOCASEL = ET_CTR_ZERO; // Enable event timebase counter equal to zero, SOCA pulse generated
EPwm1Regs.ETSEL.bit.INTEN = 0; // Disable the EPWM1 interrupt
// Setup Event Trigger Pre-Scale
EPwm1Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 1st event
EPwm1Regs.ETPS.bit.SOCAPRD = ET_1ST; // Generate pulse on 1st event
EPwm1Regs.ETPS.bit.SOCBPRD = ET_1ST; // Generate pulse on 1st event
Sets up ADC:
AdcRegs.ADCMAXCONV.all = 7; //Setup no. of conv's
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 6; //ADCINA0 - CURRRENT (actually a POT)
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 4; //ADCINA4 - DC_VOLTS
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 6; //ADCINA0 - CURRRENT (actually a POT)
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 4; //ADCINA4 - DC_VOLTS
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 3; //ADCINA3 - RECT
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 8; //ADCINB0 - 15V
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 10; //ADCINB2 - THERM2
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 11; //ADCINB3 - THERM1
AdcRegs.ADCTRL1.all = 0x0000;
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; //Reset SEQ1
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1; //Enable SOCA from ePWM to start SEQ1
AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ2 = 0; //Disable SOCB from ePWM to start SEQ2
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; //Enable SEQ1 interrupt (every EOS)
PieCtrlRegs.PIEIER1.bit.INTx6 = 1; /// Enable ADC interrupt
Then I enable interrupts via PieCtrlRegs.PIECTRL.bit.ENPIE and IER..
My ADC interrupt saves the values from the result buffers immediately.
I've got the two CURRENT conversions connected to the arm of a 10kohm POT across 3.3 V, allowing me to select any voltage across the ADC's range:
void PWM_ISR(void)
{
uint16_t POT1 = AdcRegs.ADCRESULT0>>4;
uint16_t POT2 = AdcRegs.ADCRESULT2>>4;
gRS485.printf("%d - %d\r\n", POT1, POT2);
...
This is the output (@ 5 kHz)
3771 - 3766
3783 - 3808
3790 - 3770
3788 - 3770
3771 - 3824
3752 - 3769
3748 - 3770
3788 - 3770
3778 - 3766
3771 - 3594
3724 - 3770
3782 - 1760
3783 - 1760
3771 - 3750
3766 - 3810
3770 - 3769
3780 - 3769
3771 - 3762
3776 - 3642
3776 - 3766
3764 - 3826
3776 - 3769
3771 - 3608
3780 - 3763
3778 - 3770
3764 - 3772
3757 - 3761
3764 - 1766
3778 - 1764
3770 - 3772
3778 - 3771
3789 - 1764
I've highlighted the values that have dropped the top bit.
Interestingly it doesn't seem to happen to the first conversion, only the second.
This isn't due to the POT itself, I noticed it first on a different channel (15V line - ADCINB0) which was set up to scale from 0 V to 30 V, so the nominal 15 V was sometimes coming up as 14.9 V and sometimes 0 V - 0.5 V as the top bit stayed clear.
I've tried two separate control cards to no avail.
Any suggestions? I've directly measured the voltage going into the ADC line and it is correct.
The PWM is set to fire at 5 kHz - not particularly fast.
Cheers,
Kyle