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.

Help

Other Parts Discussed in Thread: TMS320F2812

I am trying to understand some labs but I dont understand what  this Din=GpiodataRegs.GPBDAT>all..8 mean in the source file

Thanks

Hamdi Albunashee

 

  • Hi Hamdi, 

    It signifies the data of all the GPIOs in Group B. Then inputting their values to Din. 

    Regards, 

    Gautam

  • Hi Gautam and thank you,

    What about the number 8, what that mean?

    thank you

  • Hamdi, "..8" feels like a wrong syntax. Where did you extract this line from? Let me know, I'll check and come back to you then.

    Regards,

    Gautam

  • Actually, I`m a master student and I have class "microcontroller". The professor teaches us DSP c2000, TMS320F2812 and he starts to execute some labs as shown in attached file

    page numbers 15-30

    This is the whole program

    void InitSystem(void);
    void delay_loop(long);
    void InitGpio(void);



    void main(void)
    {
        unsigned int i, Din;
        unsigned long var, K=100000;
        unsigned int LED[8]= {0x0001,0x0002,0x0004,0x0008,
                              0x0010,0x0020,0x0040,0x0080};
        
        InitSystem();
        InitGpio();        // Initialize the GPIO's

        while(1)
        {    
            //add the instructions here for Lab3
        for (i=0;i<14;i++)
            {
                if(i<7)
                {
                    GpioDataRegs.GPBDAT.all = LED[i];
                }
                else
                {
                GpioDataRegs.GPBDAT.all = LED[14-i];
                }
                Din = GpioDataRegs.GPBDAT.all>>8;
                var = K*(1+Din);
                delay_loop(var);
            }
        }
    }     

    void delay_loop(long end)
    {
        //Delay time is approximately equal to 70 ns *(end+1) when the CPU clock is 150 MHz
        long i;
        for (i = 0; i < end; i++)  
        {
        /*
            EALLOW;
            SysCtrlRegs.WDKEY = 0x55;
            SysCtrlRegs.WDKEY = 0xAA;
            EDIS;   
        */
        }
    }



    void InitGpio(void)
    {
        EALLOW;
        GpioMuxRegs.GPAMUX.all = 0x0000;    // all GPIO port Pin's to I/O
        GpioMuxRegs.GPBMUX.all = 0x0000;   
        GpioMuxRegs.GPDMUX.all = 0x0000;
        GpioMuxRegs.GPFMUX.all = 0x0000;        
        GpioMuxRegs.GPEMUX.all = 0x0000;
        GpioMuxRegs.GPGMUX.all = 0x0000;            
                                            
        GpioMuxRegs.GPADIR.all = 0x0000;    // GPIO PORT  as input
        GpioMuxRegs.GPBDIR.all = 0x00FF;    // GPIO Port B15-B8 input , B7-B0 output
        GpioMuxRegs.GPDDIR.all = 0x0000;    // GPIO PORT  as input
        GpioMuxRegs.GPEDIR.all = 0x0000;    // GPIO PORT  as input
        GpioMuxRegs.GPFDIR.all = 0x0000;    // GPIO PORT  as input
        GpioMuxRegs.GPGDIR.all = 0x0000;    // GPIO PORT  as input

        GpioMuxRegs.GPAQUAL.all = 0x0;    // Set GPIO input qualifier values to zero
        GpioMuxRegs.GPBQUAL.all = 0x0;
        GpioMuxRegs.GPDQUAL.all = 0x0;
        GpioMuxRegs.GPEQUAL.all = 0x0;
        EDIS;
    }     

    void InitSystem(void)
    {
           EALLOW;
           SysCtrlRegs.WDCR= 0x00E8;        // Setup the watchdog
                                           // 0x00E8  to disable the Watchdog , Prescaler = 1
                                           // 0x00AF  to NOT disable the Watchdog, Prescaler = 64
    /*
           SysCtrlRegs.SCSR = ?;             // Watchdog generates a RESET    
           SysCtrlRegs.PLLCR.bit.DIV = ?;    // Setup the Clock PLL to multiply by 5
        
           SysCtrlRegs.HISPCP.all = 0x?;     // Setup Highspeed Clock Prescaler to divide by 2
           SysCtrlRegs.LOSPCP.all = 0x?;     // Setup Lowspeed CLock Prescaler to divide by 4
              
           // Peripheral clock enables set for the selected peripherals.   
           SysCtrlRegs.PCLKCR.bit.EVAENCLK=0;
           SysCtrlRegs.PCLKCR.bit.EVBENCLK=0;
           SysCtrlRegs.PCLKCR.bit.SCIAENCLK=0;
           SysCtrlRegs.PCLKCR.bit.SCIBENCLK=0;
           SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0;
           SysCtrlRegs.PCLKCR.bit.SPIENCLK=0;
           SysCtrlRegs.PCLKCR.bit.ECANENCLK=0;
           SysCtrlRegs.PCLKCR.bit.ADCENCLK=0;

    3107.Module3.pdf

     

  •      Din = GpioDataRegs.GPBDAT.all>>8;

    Its >> and not ".."

    That's what I was wondering. GPBDAT.all is a 32-bit-value. Hence, if you shift right 8 times, you will get the respective GPIO from group B on the LSB. Basically you're trying to select the particular GPIOs.

    Here's an example for left shifting:

    Uint32 somedata;
    
    GpioDataRegs.GPADAT.all = somedata & 0x000000FF; //write to GPIO7-GPIO0   
    
    GpioDataRegs.GPADAT.all = (somedata << 8) & 0x0000FF00; //write to GPIO15-GPIO8   
    
    GpioDataRegs.GPADAT.all = (somedata << 16) & 0x00FF0000; //write to GPIO23-GPIO16
    
    GpioDataRegs.GPADAT.all = (somedata << 24) & 0xFF000000; //write to GPIO31-GPIO24   

    Regards,

    Gautam

  • thank you very much