Forums

McBSP as GPIO

Started by mahmood molaei March 13, 2008
Dear Group people
I am going to use three pins of Mcbsp and I read Volume 5: Enhanced Peripherals
document(section 2.9) and I wrote this program .
#include "tonecfg.h"
#include "dsk5416.h"
#include "dsk5416_pcm3002.h"
#include "csl_mcbsp.h"
#include
#include "csl_gpio.h"
#include "csl_hpihal.h"
#include "csl_gpio.h"
#include "tonecfg.h"

void delay(void)
{
long i, j=0;
for(i=0;i j++;
}

}
while(1)
{
MCBSP_RSETH(hMcbsp0, SPCR1 ,0x0000);
MCBSP_RSETH(hMcbsp0, SPCR2,0x0000);
MCBSP_RSETH(hMcbsp0, PCR,0x2a0a);
delay();
MCBSP_RSET(PCR0, 0x2a00);
MCBSP_RSETH(hMcbsp0, PCR,0x2a00);
delay();
}
void main()
{
// Initialize the board support library
DSK5416_init();
}

Also I configured McBSP on CSL as GPIO port .
the program is built without any error.
I connected an LED to DC_BCLKX0 on DSK5416 but it didn't work.
Do you know what wrong is with it.

would you please help me.

Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467
Mahmood-

Your code is kinda messed up. You have code outside of main() that will never run,
because processing after Reset starts from main(). Here is some pseudo code, try to
understand this:

void main() { /* code starts here after Reset */

DSK5416_init(); /* init board */
init CSL /* init CSL (if needed) */

while (1) { /* forever loop, do not exit main */

toggle GPIO pin /* connected to LED &/

very long delay /* > 1/4 sec to make toggle clearly visible */
}
}

Also, when you say "I connected an LED to DC_BCLKX0" bit, it sounds to me like you
connected an LED directly and are expecting it to work. You need something like
this:

O 3.3V
|
/
\ 330 ohm
/
_|_
_\_/_ LED
|
DC_BCLKX0 -----+

In this case, when DC_BCLKX0 is low, the LED will turn on. You need to be careful
not to put too much current through the DSP's GPIO pins. In the above case, the
current is about 10 mA -- you should check the 5416 data sheet and make sure that's
within the spec for the chip's GPIO pins.

-Jeff

mahmood molaei wrote:
>
> Dear Group people
> I am going to use three pins of Mcbsp and I read Volume 5: Enhanced Peripherals
> document(section 2.9) and I wrote this program .
> #include "tonecfg.h"
> #include "dsk5416.h"
> #include "dsk5416_pcm3002.h"
> #include "csl_mcbsp.h"
> #include
> #include "csl_gpio.h"
> #include "csl_hpihal.h"
> #include "csl_gpio.h"
> #include "tonecfg.h"
>
> void delay(void)
> {
> long i, j=0;
> for(i=0;i > j++;
> }
>
> }
> while(1)
> {
> MCBSP_RSETH(hMcbsp0, SPCR1 ,0x0000);
> MCBSP_RSETH(hMcbsp0, SPCR2,0x0000);
> MCBSP_RSETH(hMcbsp0, PCR,0x2a0a);
> delay();
> MCBSP_RSET(PCR0, 0x2a00);
> MCBSP_RSETH(hMcbsp0, PCR,0x2a00);
> delay();
> }
> void main()
> {
> // Initialize the board support library
> DSK5416_init();
>
> }
>
> Also I configured McBSP on CSL as GPIO port .
> the program is built without any error.
> I connected an LED to DC_BCLKX0 on DSK5416 but it didn't work.
> Do you know what wrong is with it.
Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467
Mahmood-
> Thank you very much for your kindly help
> it worked

Ok glad to hear that! Keep going.

Please post to the group (not to me) so other students doing similar projects can see
your results. Now that you are getting your DSP programs to run, other students may
want to ask you questions :-)

-Jeff
> Jeff Brower wrote:
>
> Mahmood-
>
> Your code is kinda messed up. You have code outside of main() that will
> never run,
> because processing after Reset starts from main(). Here is some pseudo
> code, try to
> understand this:
>
> void main() { /* code starts here after Reset */
>
> DSK5416_init(); /* init board */
> init CSL /* init CSL (if needed) */
>
> while (1) { /* forever loop, do not exit main */
>
> toggle GPIO pin /* connected to LED &/
>
> very long delay /* > 1/4 sec to make toggle clearly visible */
> }
> }
>
> Also, when you say "I connected an LED to DC_BCLKX0" bit, it sounds to me
> like you
> connected an LED directly and are expecting it to work. You need
> something like
> this:
>
> O 3.3V
> |
> /
> \ 330 ohm
> /
> _|_
> _\_/_ LED
> |
> DC_BCLKX0 -----+
>
> In this case, when DC_BCLKX0 is low, the LED will turn on. You need to be
> careful
> not to put too much current through the DSP's GPIO pins. In the above
> case, the
> current is about 10 mA -- you should check the 5416 data sheet and make
> sure that's
> within the spec for the chip's GPIO pins.
>
> -Jeff
>
> mahmood molaei wrote:
> >
> > Dear Group people
> > I am going to use three pins of Mcbsp and I read Volume 5: Enhanced
> Peripherals
> > document(section 2.9) and I wrote this program .
> > #include "tonecfg.h"
> > #include "dsk5416.h"
> > #include "dsk5416_pcm3002.h"
> > #include "csl_mcbsp.h"
> > #include
> > #include "csl_gpio.h"
> > #include "csl_hpihal.h"
> > #include "csl_gpio.h"
> > #include "tonecfg.h"
> >
> > void delay(void)
> > {
> > long i, j=0;
> > for(i=0;i
> > j++;
> > }
> >
> > }
> > while(1)
> > {
> > MCBSP_RSETH(hMcbsp0, SPCR1 ,0x0000);
> > MCBSP_RSETH(hMcbsp0, SPCR2,0x0000);
> > MCBSP_RSETH(hMcbsp0, PCR,0x2a0a);
> > delay();
> > MCBSP_RSET(PCR0, 0x2a00);
> > MCBSP_RSETH(hMcbsp0, PCR,0x2a00);
> > delay();
> > }
> > void main()
> > {
> > // Initialize the board support library
> > DSK5416_init();
> >
> > }
> >
> > Also I configured McBSP on CSL as GPIO port .
> > the program is built without any error.
> > I connected an LED to DC_BCLKX0 on DSK5416 but it didn't work.
> > Do you know what wrong is with it.
>
> ------------
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.