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.

ADC and PWM synchronization on 28335

Other Parts Discussed in Thread: SYSBIOS

Okay, my problem seems to have a lengthy description, so I apologize:

I am using:

CCS 5.4.0

Bios 6.35.3

XDC 3.25.2

A custom 28335 based mainly on an EZDSP board

 I recently converted a project from DSP/BIOS and have the program executing correctly (I think) except for the ADC and PWM calculations.

The hardware is basically a DC/DC converter with the PWMs controlling IGBTs.

The ADC is initialized like so:

7802.InitADC.txt

In the program a HWI is triggered via the PIE 1.6 ADCINT, which posts a SWI depending on if a SEQ1 or SEQ2 conversion took place.  In the SEQ1 ISR the first thing done is set a flag for which PWM triggered the conversion, like so:

if (EPwm1Regs.ETFLG.bit.SOCA == 1)     // conversion triggered by PWM phase A

                        {

                                                EPwm1Regs.ETCLR.bit.SOCA = 1;             // clear the flag denoting SOC started by phase A

                                                PWMState = STATE_EOC_PHASE_A;       // Denote that the PWM module state is such that phase A conversion just completed

                        phaseA = phaseA+1;

                        }

Then, it checks whether the ADC conversion took the measurement corresponding to the PWM trigger.

 

                        if (AdcRegs.ADCASEQSR.bit.SEQ1_STATE == STATE_EOC_PHASE_A && PWMState == STATE_EOC_PHASE_A)                   // Measurements corresponding to phase A just completed

                        {

                                                WrnFlags.Wrn0.bit.L0_ADCPHS = 0;      // Clear Warning flag, since the ADC and PWM phases match

 

From there it pulls the measurement from the shadow register, scales it, and stores it. Then it looks to be sure it’s not in an overvoltage condition, then see’s if it happened fast enough to go into the current loop via another SWI.

if ( (DSP_State != S_INIT) && (EQep1Regs.QFLG.bit.INT != 1) && (EPwm1Regs.TBCTR > pwmfullduty/2)) // If more than 1/4 PWM period has passed since SOC was initiated

                                                {

                                                                        SetFault();                                                                                                                                                     // Set DSP to fault state

                                                                        ErrFlags.Err1.bit.L6_ADCSLOW = 1;         // Set flag indicating ADC conversion process too slow.

                                                }

-When I execute this in DSP/BIOS, with a cpuFreq of 150MHz, and a PWM frequency of 4kHz, it has very even numbers for debugging counters I put in each of the Phase A, Phase B, and Phase C measurement loops (even though Phase C is not being used, it is still in there because of the hardware).

 

-When nothing is changed in the setup or configuration code, except for the conversion to SYS/BIOS, the measurement loop counts are all over the place, usually excluding phase B.

 

 

This seems to be some kind of synchronization problem, but I can’t figure out why.  The PLLs lock, and everything else seems to be operating as expected.

There is one difference, however.  Due to size constraints, I am no longer able to run the .econst section out of RAM, and have kept it in flash.  Other than that, everything else about the code is identical.

Here are the map files for DSP/BIOS

 5635.Semikron_DCDC_v05.txt

And SYS/BIOS

4743.Semikron_SYSBIOS.txt

  • Can you confirm you have the CPU speed and Clock are set-up correctly? One simple test we like to do is load the program and let it run for a few seconds. Look at ROV->Clock module and see what the clockTick is. Let it run for 30 seconds. Look at the clockTick value. It should have increased by ~30000 (assuming you are using the default 1ms clock tick period).

    Todd

  • Well, I haven't nailed down what is causing it yet, but I can only run for about 10 seconds before the program restarts and re-initializes.  If I halt it before then, it does look like what it's supposed to be. (about 5 seconds gave me 4760 1 ms ticks.)

  • I'm finally able to get back to this project and look a little further into it. 

    It seems as though, when I'm running for the first few seconds, everything is fine.  The ROV has valid info, the clock ticks are matching what they should for a 1 ms clockTick, no errors are seen in the ROV.  But if I let it run for a few more seconds, something goes wrong.  The ROV then throws an exception "Target memory read failed at address: 0x448660d, length: 4"

    I don't know how to determine what is causing this.