DSPRelated.com
Forums

TMS320vc5510 dsk :MCBSP operate as slave

Started by teik...@yahoo.com December 26, 2006
HI, I am Ang From Universiti Teknologi Malaysia.now i am having a problem on SPI operation for TMS320vc5510 DSK operate as slave device while my PIC18F452 operate as master.
I try SPI on two microcontroller , it is working,
but when i try PIC18f452 and TMS320VC5510 DSK, it doesn't work.

what i want to do is:
1.PIC18f452 will send 1 byte of data to TMS320vc5510 DSK.
2.then if TMS320vc5510 DSK receive the one byte data, it will blink the led.

The problem is on TMS320vc5510 DSK.I am new to TMS320vc5510 DSK.Below are my complete coding for TMS320vc5510 DSK to operate as a slave.
Please help me.
//my coding:
#include "ledcfg.h" //i use csl gui to configure my mcbsp0
#include "dsk5510.h"
#include "dsk5510_led.h"
#include "dsk5510_dip.h"
void spi_init();
Uint32 delay;
Uint16 val;

void main()
{
spi_init();
CSL_cfgInit();

MCBSP_start(hMcbsp0, MCBSP_SRGR_START, 0xFFFF);
MCBSP_start(hMcbsp0, MCBSP_XMIT_START, 0xFFFF);
MCBSP_start(hMcbsp0, MCBSP_RCV_START, 0xFFFF);
while(1)
{
while (!MCBSP_rrdy(hMcbsp0));
val=MCBSP_read16(hMcbsp0);
while (!MCBSP_xrdy(hMcbsp0));
MCBSP_write16(hMcbsp0, 0x0001);
MCBSP_close(hMcbsp0);

if (val==0x0001)
{
/* Initialize the board support library, must be first BSL call */
DSK5510_init();

/* Initialize the LED and DIP switch modules of the BSL */
DSK5510_LED_init();
DSK5510_DIP_init();

while(1)
{
/* Toggle LED #0 */
DSK5510_LED_toggle(0);

/* Check DIP switch #3 and light LED #3 accordingly, 0 = switch pressed */
if (DSK5510_DIP_get(3) == 0)
/* Switch pressed, turn LED #3 on */
DSK5510_LED_on(3);
else
/* Switch not pressed, turn LED #3 off */
DSK5510_LED_off(3);

/* Spin in a software delay loop for about 200ms */
for (delay = 0; delay < 3000000; delay++);
}}
}}

void spi_init()
{

MCBSP_FSET(SPCR10,RRST,0); //reset Rx
MCBSP_FSET(SPCR20,XRST,0); //reset Tx
MCBSP_FSET(SPCR20,GRST,0); //reser sample rate generator
}
First get an oscilloscope to watch the signals.

I guess the problem lies in the following code. You'd better add some delay before closing the McBsp. Otherwise, the McBsp is turned off because it starts to shift the bits. For details there was a discussion in this board in 2006.

Wei

> while(1)
> {
>while (!MCBSP_rrdy(hMcbsp0));
> val=MCBSP_read16(hMcbsp0);
> while (!MCBSP_xrdy(hMcbsp0));
> MCBSP_write16(hMcbsp0, 0x0001);
ADD DELAY
> MCBSP_close(hMcbsp0);
Ang Teik Boon-

> HI, I am Ang From Universiti Teknologi Malaysia.now i am having a problem on
> SPI operation for TMS320vc5510 DSK operate as slave device while my PIC18F452
> operate as master.
> I try SPI on two microcontroller , it is working,
> but when i try PIC18f452 and TMS320VC5510 DSK, it doesn't work.
>
> what i want to do is:
> 1.PIC18f452 will send 1 byte of data to TMS320vc5510 DSK.
> 2.then if TMS320vc5510 DSK receive the one byte data, it will blink the led.
>
> The problem is on TMS320vc5510 DSK.I am new to TMS320vc5510 DSK.Below are my
> complete coding for TMS320vc5510 DSK to operate as a slave.
> Please help me.

In addition to Li Wei's comments about delay prior to McBSP_close() (excellent
point), where is your McBSP_open() call? I don't see where hMcBSP0 is declared or
initialized.

-Jeff
> //my coding:
>
> #include "ledcfg.h" //i use csl gui to configure my mcbsp0
> #include "dsk5510.h"
> #include "dsk5510_led.h"
> #include "dsk5510_dip.h"
>
> void spi_init();
> Uint32 delay;
> Uint16 val;
>
> void main()
> {
> spi_init();
> CSL_cfgInit();
>
> MCBSP_start(hMcbsp0, MCBSP_SRGR_START, 0xFFFF);
> MCBSP_start(hMcbsp0, MCBSP_XMIT_START, 0xFFFF);
> MCBSP_start(hMcbsp0, MCBSP_RCV_START, 0xFFFF);
>
> while(1)
> {
> while (!MCBSP_rrdy(hMcbsp0));
> val=MCBSP_read16(hMcbsp0);
> while (!MCBSP_xrdy(hMcbsp0));
> MCBSP_write16(hMcbsp0, 0x0001);
> MCBSP_close(hMcbsp0);
>
> if (val==0x0001)
> {
> /* Initialize the board support library, must be first BSL call */
> DSK5510_init();
>
> /* Initialize the LED and DIP switch modules of the BSL */
> DSK5510_LED_init();
> DSK5510_DIP_init();
>
> while(1)
> {
> /* Toggle LED #0 */
> DSK5510_LED_toggle(0);
>
> /* Check DIP switch #3 and light LED #3 accordingly, 0 = switch pressed */
> if (DSK5510_DIP_get(3) == 0)
> /* Switch pressed, turn LED #3 on */
> DSK5510_LED_on(3);
> else
> /* Switch not pressed, turn LED #3 off */
> DSK5510_LED_off(3);
>
> /* Spin in a software delay loop for about 200ms */
> for (delay = 0; delay < 3000000; delay++);
> }}
> }}
>
> void spi_init()
> {
>
> MCBSP_FSET(SPCR10,RRST,0); //reset Rx
> MCBSP_FSET(SPCR20,XRST,0); //reset Tx
> MCBSP_FSET(SPCR20,GRST,0); //reser sample rate generator
> }
Ang Teik Boon-
> thanks you for replying my problem.
> For your information, i use CSL(chip support library) to configure my MCBSP0.
> so my hmcbsp0 is in the generated source file.c file.did u get it?

No I don't see hMcBSP0 declared -- or referenced as extern -- in the code below.
> or can u give me some working example of initialization or cnfiguration?thanks you

Are you saying that you can't find some example source code for CSL + McBSP + DSK
5510 and you want me to find it for you? C'mon. CCS is full of such examples. You
are one of 100s of students working on similar projects, so I'm sure you can find the
code.

When you have specific problems and you've tried hard to debug them -- that's the
time to ask for help.

-Jeff
> Jeff Brower wrote:
>
> Ang Teik Boon-
>
> > HI, I am Ang From Universiti Teknologi Malaysia.now i am having a
> problem on
> > SPI operation for TMS320vc5510 DSK operate as slave device while my
> PIC18F452
> > operate as master.
> > I try SPI on two microcontroller , it is working,
> > but when i try PIC18f452 and TMS320VC5510 DSK, it doesn't work.
> >
> > what i want to do is:
> > 1.PIC18f452 will send 1 byte of data to TMS320vc5510 DSK.
> > 2.then if TMS320vc5510 DSK receive the one byte data, it will blink the
> led.
> >
> > The problem is on TMS320vc5510 DSK.I am new to TMS320vc5510 DSK.Below
> are my
> > complete coding for TMS320vc5510 DSK to operate as a slave.
> > Please help me.
>
> In addition to Li Wei's comments about delay prior to McBSP_close()
> (excellent
> point), where is your McBSP_open() call? I don't see where hMcBSP0 is
> declared or
> initialized.
>
> -Jeff
> > //my coding:
> >
> > #include "ledcfg.h" //i use csl gui to configure my mcbsp0
> > #include "dsk5510.h"
> > #include "dsk5510_led.h"
> > #include "dsk5510_dip.h"
> >
> > void spi_init();
> > Uint32 delay;
> > Uint16 val;
> >
> > void main()
> > {
> > spi_init();
> > CSL_cfgInit();
> >
> > MCBSP_start(hMcbsp0, MCBSP_SRGR_START, 0xFFFF);
> > MCBSP_start(hMcbsp0, MCBSP_XMIT_START, 0xFFFF);
> > MCBSP_start(hMcbsp0, MCBSP_RCV_START, 0xFFFF);
> >
> > while(1)
> > {
> > while (!MCBSP_rrdy(hMcbsp0));
> > val=MCBSP_read16(hMcbsp0);
> > while (!MCBSP_xrdy(hMcbsp0));
> > MCBSP_write16(hMcbsp0, 0x0001);
> > MCBSP_close(hMcbsp0);
> >
> >
> >
> > if (val==0x0001)
> > {
> > /* Initialize the board support library, must be first BSL call */
> > DSK5510_init();
> >
> > /* Initialize the LED and DIP switch modules of the BSL */
> > DSK5510_LED_init();
> > DSK5510_DIP_init();
> >
> > while(1)
> > {
> > /* Toggle LED #0 */
> > DSK5510_LED_toggle(0);
> >
> > /* Check DIP switch #3 and light LED #3 accordingly, 0 = switch pressed
> */
> > if (DSK5510_DIP_get(3) == 0)
> > /* Switch pressed, turn LED #3 on */
> > DSK5510_LED_on(3);
> > else
> > /* Switch not pressed, turn LED #3 off */
> > DSK5510_LED_off(3);
> >
> > /* Spin in a software delay loop for about 200ms */
> > for (delay = 0; delay < 3000000; delay++);
> > }}
> > }}
> >
> > void spi_init()
> > {
> >
> > MCBSP_FSET(SPCR10,RRST,0); //reset Rx
> > MCBSP_FSET(SPCR20,XRST,0); //reset Tx
> > MCBSP_FSET(SPCR20,GRST,0); //reser sample rate generator
> > }
>