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.

CCS/TMS320F28027: AdcNetBus and ADCDRV_1ch_Rlt2

Part Number: TMS320F28027
Other Parts Discussed in Thread: BOOSTXL-C2KLED, CONTROLSUITE

Tool/software: Code Composer Studio

Hello

How is AdcNetBus or ADCDRV_1ch_Rlt2 retreived and passed to the controller say 2p2z?

maybe I have the same question as https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/126212/451361 

  • Victor,
    Can you give the source project name and path for the code in question?

    Thanks,
    Matthew
  • Hello Matt,

    I was trying to understand the code from BOOSTXL-C2KLED 2p2z connections, say boost 1 (BLUE):

    // Boost 1 connections
    ADCDRV_1ch_Rlt1 = &AdcNetBus[1];
    CNTL_2P2Z_Ref1 = &IrefNetBus1; // point to Iref1
    CNTL_2P2Z_Fdbk1 = &AdcNetBus[1]; // point to Iout1
    CNTL_2P2Z_Coef1 = &CNTL_2P2Z_CoefStruct1.b2; // point to first coeff of 1st loop
    CNTL_2P2Z_Out1 = &UoutNetBus1; // point to 2P2Z Uout1
    PWMDRV_2ch_UpCnt_Duty1A = &UoutNetBus1;

    The feedback is coming from the current sense resistor voltage multiplied by the gain of the OPAmp to the ADC, IBLUE (ADCINA2) .
    Say later on, still using BOOSTXL-C2KLED, I will make a boost conv with feedback coming from the voltage divider VBLUE (ADCINB1), of course my K will change accordingly.
    But how do I redirect AdcNetBus to get the "new" feedback from IBLUE (ADCINA2) to VBLUE (ADCINB1)?
  • Victor,

    Thanks, here goes:

    The ADC Results get stored in long array AdcNetBus[16].  This is a linear store of the ADC Result Registers 0 -15.

    Now, the channels that get sampled when the ADC triggers are defined starting at line 516 in LED_Boost_PC_Main.c as follows:

    #define        Iout1R    AdcResult.ADCRESULT1        //Q12
    #define        Iout2R    AdcResult.ADCRESULT2        //Q12
    #define        Iout3R    AdcResult.ADCRESULT3        //Q12
    #define        Vout1R    AdcResult.ADCRESULT9        //Q12
    #define        Vout2R    AdcResult.ADCRESULT10       //Q12
    #define        Vout3R    AdcResult.ADCRESULT11       //Q12
    #define        VinR      AdcResult.ADCRESULT12       //Q12
    
        //
        // ADC Channel Selection
        //
        ChSel[0] = 2;        // Dummy read for first sample bug
        ChSel[1] = 2;        // A2 - Iout1 - blue
        ChSel[2] = 1;        // A1 - Iout2 - green
        ChSel[3] = 6;        // A6 - Iout3 - red
        ChSel[9] = 9;        // B1 - Vout1
        ChSel[10] = 10;      // B2 - Vout2
        ChSel[11] = 12;      // B3 - Vout3
        ChSel[12] = 14;      // B6 - Vin / Vout8
    
        //
        // ADC Trigger Selection
        //
        TrigSel[0] = 5;        // ePWM1, ADCSOCA
        TrigSel[1] = 5;        // ePWM1, ADCSOCA
        TrigSel[2] = 5;        // ePWM1, ADCSOCA
        TrigSel[3] = 5;        // ePWM1, ADCSOCA
        TrigSel[9] = 5;        // ePWM1, ADCSOCA
        TrigSel[10] = 5;       // ePWM1, ADCSOCA
        TrigSel[11] = 5;       // ePWM1, ADCSOCA
        TrigSel[12] = 5;       // ePWM1, ADCSOCA
    
        ADC_SOC_CNF(ChSel, TrigSel, ACQPS, 16, 0);

    So as you pointed out Iout1R is coming from ADCINA2, Iout2R is from ADCINA1, and so on.  All ADC channels are sampled when SOCA trigger from ePWM1 happens.  So if you want to change the ADC channel that samples Iout1R, you would just need to change the channel number at ChSel[1].  

    After the ADC completes its conversions, the ADC Results are loaded to AdcNetBus[16] in the DPL_ISR, which is in LED_Boost_PC_ISR.asm.  This uses an assembly macro in ADCDRV_1ch.asm to transfer the 12-bit result to a left justified 32-bit word(recall that AdcNetBus[16] was defined as a long), such that the ADC Result is in Q24 format.

    I believe that the array AdcNetBus[16] holds each result from the ADC, even if they are unused(i.e. 0, 4-8, and 13-15).

    Let me know if this answers the question.

    Best,

    Matthew

  • Hello Matthew,

    Thanks for the answer. I just thought so too, changing and redirecting by ChSel[x].

    I did the same when I convert the firmware for TMDSRGBLEDKIT firmware but still using BOOSTXL-C2KLED hardware as I asked in the link below.
    As I thought the software is modifiable and able to adapt on a certain hardware.

    e2e.ti.com/.../2483841

    I was trying to use the firmware of TMDSRGBLEDKIT

    C:\ti\controlSUITE\development_kits\Multi-DCDC-Color-LED-Kit_v1.0\LED-ColorMix_v1_0

    on my BOOSTXL-C2KLED.

    Open loop is working and can light the GREEN or RED LED but when I close the loop, I cannot seem to lit GREEN led. BTW, the BLUE LED seems to be spoilt already.

    BOOSTXL-C2KLED is using these ADC channels (/LED_Boost_PC/LED_Boost_PC_Main.c):

    // ADC Channel Selection
    ChSel[0] = 2; // Dummy read for first sample bug
    ChSel[1] = 2; // A2 - Iout1 - blue
    ChSel[2] = 1; // A1 - Iout2 - green
    ChSel[3] = 6; // A6 - Iout3 - red
    ChSel[9] = 9; // B1 - Vout1
    ChSel[10] = 10; // B2 - Vout2
    ChSel[11] = 12; // B3 - Vout3
    ChSel[12] = 14; // B6 - Vin / Vout8

    while TMDSRGBLEDKIT are using these (/TMDSRGBLEDKIT-LED-ColorMix/LED-ColorMix-Main.c):

    // ADC Channel Selection
    ChSel[0] = 2; // Dummy read for first sample bug
    ChSel[1] = 2; // A2 - Iout1
    ChSel[2] = 0; // A0 - Iout2
    ChSel[3] = 4; // A4 - Iout3
    ChSel[4] = 1; // A1 - Iout4
    ChSel[5] = 6; // A6 - Iout5
    ChSel[6] = 3; // A3 - Iout6
    ChSel[7] = 14; // B6 - Iout7
    ChSel[8] = 7; // A7 - Iout8
    ChSel[9] = 9; // B1 - Vout1
    ChSel[10] = 10; // B2 - Vout2
    ChSel[11] = 11; // B3 - Vout3
    ChSel[12] = 12; // B4 - Vin / Vout8

    few questions:
    1. why is B3 on both firmware different? 11 vs 12
    2. can I swap ADC channels? since the GREEN on BOOSTXL-C2KLED is using A1 while in TMDSRGBLEDKIT A1 is used for Iout4. It seems to work on RED LED but not on GREEN.

    Here are the modifications I did:

    // ADC Channel Selection
    ChSel[0] = 2; // Dummy read for first sample bug
    ChSel[1] = 2; // A2 - Iout1
    ChSel[2] = 1; // A0 - Iout2 , orig "0".
    ChSel[3] = 6; // A4 - Iout3, orig "4".
    ChSel[4] = 1; // A1 - Iout4, can double?
    ChSel[5] = 6; // A6 - Iout5, can double?
    ChSel[6] = 3; // A3 - Iout6
    ChSel[7] = 14; // B6 - Iout7
    ChSel[8] = 7; // A7 - Iout8
    ChSel[9] = 9; // B1 - Vout1
    ChSel[10] = 10; // B2 - Vout2
    ChSel[11] = 11; // B3 - Vout3
    ChSel[12] = 12; // B4 - Vin / Vout8

    I am modifying Gui_Iset2 & Gui_Iset3 during debug to change the light intensity. Only RED LED can be controlled (Gui_Iset3) but not GREEN (Gui_Iset2).

    Then I finally set like this:

    // ADC Channel Selection
    ChSel[0] = 2; // Dummy read for first sample bug
    ChSel[1] = 2; // A2 - Iout1
    ChSel[2] = 1; // A0 - Iout2, orig "0".
    ChSel[3] = 6; // A4 - Iout3, orig "4".
    ChSel[4] = 0; // A1 - Iout4, orig "1".
    ChSel[5] = 4; // A6 - Iout5, orig "6".
    ChSel[6] = 3; // A3 - Iout6
    ChSel[7] = 14; // B6 - Iout7
    ChSel[8] = 7; // A7 - Iout8
    ChSel[9] = 9; // B1 - Vout1
    ChSel[10] = 10; // B2 - Vout2
    ChSel[11] = 12; // B3 - Vout3, orig "11".
    ChSel[12] = 14; // B6 - Vin / Vout8, orig "12".

    still same effect. Also I cannot set to off the RED LED once I have already set it. Meaning it cannot turn off anymore if I set Gui_Iset3 = 0.
  • Victor,

    I noticed there is a similar dialogue on this thread https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/666638/2483841#2483841.  It looks like we are coming to the same conclusions(I spoke with Brett as well).  

    As he mentioned the physical connections on the BOOSTXL-C2KLED are different than the RGBLED KIT.  I can say that the ChSel[11] = 12 for the BOOSTXL-C2KLED is correct, the comment is what is wrong here.  VRED(Vout3) is on ADCINB4(see below schematic capture) on that PCB so value of "12" for the channel is correct for ADCINB4.  On the RGB kit it was ADCINB3, hence the 11 for that PCB.

    For the above for the I and V that do exist this looks correct.  Note that on the BOOSTXL-C2KLED Iout4, 5, 6 don't exist in HW and are not connected to any analog pins of the F28027 device.  My point being there is no need to sample those channels as they are floating.  I would not enable the triggers(leave as "0" vs the "5") for the float channels to save ADC sample time.

    I assume for the GUI interactions there may be differences as well that are causing your issues you'll need to examine the code.

    Best,

    Matthew

  • Hello Matthew,

    I still have the same problems and I have modified as follows:

    #define	Iout1R	AdcResult.ADCRESULT1	//Q12
    #define	Iout2R	AdcResult.ADCRESULT2	//Q12
    #define	Iout3R	AdcResult.ADCRESULT3	//Q12
    /*
    #define	Iout4R	AdcResult.ADCRESULT4	//Q12
    #define	Iout5R	AdcResult.ADCRESULT5	//Q12
    #define	Iout6R	AdcResult.ADCRESULT6	//Q12
    #define	Iout7R AdcResult.ADCRESULT7	//Q12
    #define	Iout8R AdcResult.ADCRESULT8	//Q12
    */
    #define	Vout1R	AdcResult.ADCRESULT9	//Q12
    #define	Vout2R	AdcResult.ADCRESULT10	//Q12
    #define	Vout3R	AdcResult.ADCRESULT11	//Q12
    #define	Vout8R	AdcResult.ADCRESULT12	//Q12
    #define	VinR	AdcResult.ADCRESULT12	//Q12
    
    // ADC Channel Selection
    ChSel[0] = 2; // Dummy read for first sample bug
    ChSel[1] = 2; // A2 - Iout1
    ChSel[2] = 1; // A1 - Iout2
    ChSel[3] = 6; // A6 - Iout3
    /*
    ChSel[4] = 1; // A1 - Iout4
    ChSel[5] = 6; // A6 - Iout5
    ChSel[6] = 3; // A3 - Iout6
    ChSel[7] = 14; // B6 - Iout7
    ChSel[8] = 7; // A7 - Iout8
    */
    ChSel[9] = 9; // B1 - Vout1
    ChSel[10] = 10; // B2 - Vout2
    ChSel[11] = 12; // B4 - Vout3
    ChSel[12] = 14; // B6 - Vin / Vout8
    
    // ADC Trigger Selection
    TrigSel[0] = 5;	// ePWM1, ADCSOCA
    TrigSel[1] = 5;	// ePWM1, ADCSOCA
    TrigSel[2] = 5;	// ePWM1, ADCSOCA
    TrigSel[3] = 5;	// ePWM1, ADCSOCA
    /*
    TrigSel[4] = 0;	// ePWM1, ADCSOCA
    TrigSel[5] = 0;	// ePWM1, ADCSOCA
    TrigSel[6] = 0;	// ePWM1, ADCSOCA
    TrigSel[7] = 0;	// ePWM1, ADCSOCA
    TrigSel[8] = 0;	// ePWM1, ADCSOCA
    */
    TrigSel[9] = 5;	// ePWM1, ADCSOCA
    TrigSel[10] = 5;	// ePWM1, ADCSOCA
    TrigSel[11] = 5;	// ePWM1, ADCSOCA
    TrigSel[12] = 5;	// ePWM1, ADCSOCA

    Anywhere else I need to check?

  • I have now fixed the BLUE LED. U6 got no output.
    Since the connections of the BLUE LEDs are same for both hardware, I thought the BLUE led will light.
    Still same problem.
  • Victor,
    Let's try something simple just to verify the connects are all good. After you load the code, just run it to at least past the setup phase and halt it. Now I'd like to use the register window to look at the GPIOA regs:

    1)I want to make the MUX selection for GPIO0/1/2 all 0. This will take control away from the PWM and give it back to the GPIO
    2)Then modify the corresponding bits in the GPIOADIR register to a "1". This will place the pin in output mode.
    3)Now, using the GPIOADAT register, write a "1" to the GPIO0/1/2 bits. If the value is a "1" you should see the blue/green/red light up respectively. If a "0" they should be off.

    Again I want to make sure the physical connection is good before we debug the control code.

    Let me know how this goes.

    Best regards,
    Matthew
  • Hello Matthew,

    Sorry for the late reply, been busy for a while.
    If i make the GPIO0-2 to be constant 1, the FET will be turned on for a long time and the V+ would be shorted to GND via the inductor and might spoil the FET.

    Anyway, before I make the experiment, I would always debug and run the original code to verify my setup (physical connections).

    Victor.

  • Victor,
    Can you attach or inline the PWM portions of the code, both the GPIO setup and the main PWM setup? I feel good about the ADC sampling at this point, so let's check the other side of the equation and look at how we are stimulating the FETs.

    Best,
    Matthew
  • Hello Matthew,

    I checked with a USB Scope (mine has a limited BW up to only 6MBPS).

    LED BOOST BOOSTXL-C2KLED is only swithing at 50kHz while MULTI LED TMDSRGBLEDKIT is shwithing at around 400kHZ.

    here are the registers at open loop:

    LED BOOST BOOSTXL-C2KLED
    GRP( ePWM1 )
    TBCTL Unsigned / Readable,Writeable 0x001A
    TBSTS Unsigned / Readable,Writeable 0x0001
    TBPHS Unsigned / Readable,Writeable 0x00000000
    TBCTR Unsigned / Readable,Writeable 0x0068
    TBPRD Unsigned / Readable,Writeable 0x0258
    TBPRDHR Unsigned / Readable,Writeable 0x0000
    CMPCTL Unsigned / Readable,Writeable 0x0300
    CMPA Unsigned / Readable,Writeable 0x00000000
    CMPB Unsigned / Readable,Writeable 0x021D
    AQCTLA Unsigned / Readable,Writeable 0x0090
    AQCTLB Unsigned / Readable,Writeable 0x0600
    AQSFRC Unsigned / Readable,Writeable 0x0000
    AQCSFRC Unsigned / Readable,Writeable 0x0000
    DBCTL Unsigned / Readable,Writeable 0x0000
    DBRED Unsigned / Readable,Writeable 0x0000
    DBFED Unsigned / Readable,Writeable 0x0000
    TZSEL Unsigned / Readable,Writeable 0x0000
    TZDCSEL Unsigned / Readable,Writeable 0x0000
    TZCTL Unsigned / Readable,Writeable 0x0000
    TZEINT Unsigned / Readable,Writeable 0x0000
    TZFLG Unsigned / Readable,Writeable 0x0000
    TZCLR Unsigned / Readable,Writeable 0x0000
    TZFRC Unsigned / Readable,Writeable 0x0000
    ETSEL Unsigned / Readable,Writeable 0x0A0A
    ETPS Unsigned / Readable,Writeable 0x0303
    ETFLG Unsigned / Readable,Writeable 0x0004
    ETCLR Unsigned / Readable,Writeable 0x0000
    ETFRC Unsigned / Readable,Writeable 0x0000
    PCCTL Unsigned / Readable,Writeable 0x0000
    HRCNFG Unsigned / Readable,Writeable 0x0000
    HRPWR Unsigned / Readable,Writeable 0x0000
    HRMSTEP Unsigned / Readable,Writeable 0x0000
    HRPCTL Unsigned / Readable,Writeable 0x0000
    TBPRDM Unsigned / Readable,Writeable 0x02580000
    CMPAM Unsigned / Readable,Writeable 0x00000000
    DCTRIPSEL Unsigned / Readable,Writeable 0x0000
    DCACTL Unsigned / Readable,Writeable 0x0000
    DCBCTL Unsigned / Readable,Writeable 0x0000
    DCFCTL Unsigned / Readable,Writeable 0x0000
    DCCAPCTL Unsigned / Readable,Writeable 0x0000
    DCFOFFSET Unsigned / Readable,Writeable 0x0000
    DCFOFFSETCNT Unsigned / Readable,Writeable 0x0000
    DCFWINDOW Unsigned / Readable,Writeable 0x0000
    DCFWINDOWCNT Unsigned / Readable,Writeable 0x0000
    DCCAP Unsigned / Readable,Writeable 0x0000

    MULTI LED TMDSRGBLEDKIT
    GRP( ePWM1 )
    TBCTL Unsigned / Readable,Writeable 0x0018
    TBSTS Unsigned / Readable,Writeable 0x0001
    TBPHS Unsigned / Readable,Writeable 0x00000000
    TBCTR Unsigned / Readable,Writeable 0x000D
    TBPRD Unsigned / Readable,Writeable 0x0095
    TBPRDHR Unsigned / Readable,Writeable 0x0000
    CMPCTL Unsigned / Readable,Writeable 0x0005
    CMPA Unsigned / Readable,Writeable 0x00000000
    CMPB Unsigned / Readable,Writeable 0x000E
    AQCTLA Unsigned / Readable,Writeable 0x0012
    AQCTLB Unsigned / Readable,Writeable 0x0102
    AQSFRC Unsigned / Readable,Writeable 0x0000
    AQCSFRC Unsigned / Readable,Writeable 0x0000
    DBCTL Unsigned / Readable,Writeable 0x0000
    DBRED Unsigned / Readable,Writeable 0x0000
    DBFED Unsigned / Readable,Writeable 0x0000
    TZSEL Unsigned / Readable,Writeable 0x0000
    TZDCSEL Unsigned / Readable,Writeable 0x0000
    TZCTL Unsigned / Readable,Writeable 0x0000
    TZEINT Unsigned / Readable,Writeable 0x0000
    TZFLG Unsigned / Readable,Writeable 0x0000
    TZCLR Unsigned / Readable,Writeable 0x0000
    TZFRC Unsigned / Readable,Writeable 0x0000
    ETSEL Unsigned / Readable,Writeable 0x090A
    ETPS Unsigned / Readable,Writeable 0x0707
    ETFLG Unsigned / Readable,Writeable 0x0005
    ETCLR Unsigned / Readable,Writeable 0x0000
    ETFRC Unsigned / Readable,Writeable 0x0000
    PCCTL Unsigned / Readable,Writeable 0x0000
    HRCNFG Unsigned / Readable,Writeable 0x0000
    HRPWR Unsigned / Readable,Writeable 0x0000
    HRMSTEP Unsigned / Readable,Writeable 0x0000
    HRPCTL Unsigned / Readable,Writeable 0x0000
    TBPRDM Unsigned / Readable,Writeable 0x00950000
    CMPAM Unsigned / Readable,Writeable 0x00000000
    DCTRIPSEL Unsigned / Readable,Writeable 0x0000
    DCACTL Unsigned / Readable,Writeable 0x0000
    DCBCTL Unsigned / Readable,Writeable 0x0000
    DCFCTL Unsigned / Readable,Writeable 0x0000
    DCCAPCTL Unsigned / Readable,Writeable 0x0000
    DCFOFFSET Unsigned / Readable,Writeable 0x0000
    DCFOFFSETCNT Unsigned / Readable,Writeable 0x0000
    DCFWINDOW Unsigned / Readable,Writeable 0x0000
    DCFWINDOWCNT Unsigned / Readable,Writeable 0x0000
    DCCAP Unsigned / Readable,Writeable 0x0000
  • Hello,

    For TMDSRGBLEDKIT

    #define prd 150 // 150 Period count = 400 KHz @ 60 MHz
    ADC_SOC_CNF(ChSel, TrigSel, ACQPS, 16, 0);
    PWM_2ch_UpCnt_CNF(1, prd, 1, 0);
    PWM_2ch_UpCnt_CNF(2, prd, 0, 2);
    PWM_2ch_UpCnt_CNF(3, prd, 0, 2);
    PWM_2ch_UpCnt_CNF(4, prd, 0, 2);

    For BOOSTXL-C2KLED

    #define prd 1200 // 1200 Period count = 50 KHz @ 60 MHz
    ADC_SOC_CNF(ChSel, TrigSel, ACQPS, 16, 0);
    PWM_DualUpDwnCnt_CNF(1, prd, 1, 0);
    PWM_DualUpDwnCnt_CNF(2, prd, 0, 400);
    PWM_1ch_UpDwnCnt_CNF(3, prd, 0, 400);
  • Victor,
    Sorry for the lapse in response. I still think there may be multiple threads on this topic, with different TI factory folks responding. Can you let me know where things are wrt to the above so I can make sure to not duplicate answers?

    Best regards,
    Matt
  • Hello Matthew,

    There is a reply already... e2e.ti.com/.../2524668
    You may close..