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.

Using Mcbsp as GPIO on c6713

Hi,

Could someone please give me some information on how to use the Mcbsp port as GPIO. I have read through the Mcbsp reference guide chapter 10 and it is still unclear. I understand, for example, that in order to use the DX pin as gpio you need to:

set (R/X)RST = 0 in SPCR
set (R/X)IOEN = 1 in PCR

set the register bit 5 of 0x018C0024 to 1 or 0

However, there are no examples on the syntax of this (which there should be) so I could use some help. How do I specifically set this bit of the register to a high or low state? Also, is this a good solution for toggling a pin for PWM? I notice that it says that the Mcbsp should be halted when changing states. Some help would be appreciated since I have noticed that it takes awhile for any responses on this forum.

Brady

  • Hi Brady,

    Thanks for your post.

    In my understanding, DXSTAT (bit5 in PCR) shall be configured to logic low(0) or logic high (1) and it is your choice but the value of DXSTAT bit you configure in PCR is driven to DX pin which reflects the status (logic low or logic high) when configured as a general purpose output pin.

    The only condition you need to meet is to set XIOEN = 1 in PCR and ensure DX pin is configured as general purpose output pin and do not perform serial port operations.

    Also, XRST = 0 in SPCR should be taken care which ensure serial port transmitter is diabled and in reset state.

    I suggest you to use the recent version of SPRU580G, Section 10 seems to be same between SPRU580C & G but the table is numbered 16 in rev C and 17 in rev G. You can use the transmit portion of the McBSP pins as GPIO and still use the receive portion to receive data normally.

    http://www.ti.com/lit/ug/spru580g/spru580g.pdf

    I do agree that, this would be the good solution for toggling a pin from high to low state and vice versa for PWM.

    Also, please refer the below E2E thread for undestanding of McBSP pin to be configured for GPIO functionality as below:

    http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/t/28104.aspx

    http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/t/107347.aspx

     

    Thanks & regards,

    Sivaraj K

    ------------------------------------------------------------------------------------------------------- 
    Please click the Verify Answer button on this post if it answers your question.
    --------------------------------------------------------------------------------------------------------

     

     

     

  • Hi Sivaraj K,

    I have seen these threads and I have tried the top one:

    http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/t/28104.aspx

    in which he uses the "outdata" and toggles that way but it does not work. Notice that there are two different DSPs here. Mine is a c6713 and that one is a c6474. Does this matter or do they still use the same syntax? I am looking for a line of code or snippet with the correct syntax to toggle one of these gpio pins (essentially a register bit right?). Do you have that? The reference, SPRU580C & G,  merely says what to do but does not say how to do it. Thanks for your reply and I appreciate your help.

    Brady

  • Hi Sivaraj K,

    So for now I have been using Timer0 and Timer1 as GPIOs. This has been working well. The way I set the data high or low is with the following code:

    while(cnt <= TIMER_CNT){
    TIMER_setDatOut(hTimer0, 0x0);
    for(countTransmit = 0; countTransmit <= 100; countTransmit++){
         for(count = 0; count<=10;count++){
              TIMER_setDatOut(hTimer1, 0x0);
         }
         for(count = 0; count<=10;count++){
              TIMER_setDatOut(hTimer1, 0x0);
         }

    }
    TIMER_setDatOut(hTimer0, 0xFFFFFFFF);
         for(countTransmit = 0; countTransmit <= 100; countTransmit++){
              for(count = 0; count<=10;count++){
                   TIMER_setDatOut(hTimer1, 0xFFFFFFFF);
              }
              for(count = 0; count<=10;count++){
                   TIMER_setDatOut(hTimer1, 0x0);
              }
        }
    }

    I am using two timers. Timer1 is responsible for the signal and Timer0 is responsible to enclose the signal packet, basically for enable or to know when I am "transmitting". This has been working well and offers flexibility.

    I am still interested in the Mcbsp ports as GPIO so if you could fill me in on that I would appreciate it. I am basically looking for a line similar to the "TIMER_setDatOut(hTimer0, 0x0); " line but for the Mcbsp port.

    Brady

  • Brady,

    Since you are using the TIMER_setDatOut function, you have the CSL loaded for the C6713. Please take a look in the documentation that accompanies that CSL to find the CSL functions that correspond to the McBSP.

    A really good way to learn some of the lower-level syntax is to read through the CSL source files. It can help your C programming skills for embedded programming with the C6713 and it can help you understand exactly what and how these functions work.

    You have some interesting code shown above. You will want to single-step through the code to see how it works, how many times the TIMER_setDatOut functions are called, and look at how the cnt variable is incremented. How many pulses of Timer1's output do you expect to see for each pulse of Timer0's output? How many do you see on a scope while running this function?

    Regards,
    RandyP