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.

c6457 Mcbsp used as SPI doubt

 i configured the mcbsp0 on c6457 as spi master, after configer each register,  i meet with the problem that when i  doesn't set the GRST(in the SPCR register )as 1 for all the time, I can get the signel of  FSX, DX,CLKX on oscilloscope which seems normal, and of cause, it doesn't  division the frequency,the frequency is too high to use. but when i set the GRST as 1, the signal are all gone, i can get nothing on oscilloscope. i doubt it is because i didn't set the register right, but i follow the step of mcbsp configer as spi  grimly. now i don't konw what to do.can anyone helps? thanks very much. Here is my code:#include<stdio.h>
#include<csl.h>
#include<csl_mcbsp.h>
#include<string.h>
#include<csl_chip.h>

CSL_McbspHandle       hMcbsp;

#define WAIT_FOR_2_CLK  do {                                   \
                            volatile int delayCnt = 2;      \
                            while(delayCnt > 0) --delayCnt; \
                           }while (0)
void DSP_MCBSP_Init()
{

 CSL_McbspObj        mcbspObj;
    CSL_Status            status;
    CSL_McbspConfig MyConfig;
    CSL_BitMask16        ctrlMask;
    MyConfig.SPCR=0x02001000;//

    MyConfig.RCR=0x7f050000;//0x00040000;
    MyConfig.XCR=0x00050000;//00010000
    MyConfig.SRGR=0x20001350;//0xb0200150;
    MyConfig.MCR= 0x00000000;
    MyConfig.RCERE0=0x00000000;
    MyConfig.RCERE1=0x00000000;
    MyConfig.RCERE2=0x00000000;
    MyConfig.RCERE3=0x00000000;
    MyConfig.XCERE0=0x00000000;
    MyConfig.XCERE1=0x00000000;
    MyConfig.XCERE2=0x00000000;
    MyConfig.XCERE3=0x00000000;
    MyConfig.PCR=0x00000A0C;//0x00000a0c;

    memset (&mcbspObj, 0, sizeof(CSL_McbspObj));

 CSL_mcbspInit (NULL);
 hMcbsp = CSL_mcbspOpen (&mcbspObj, CSL_MCBSP_0, NULL, &status);
 ctrlMask=0;
 ctrlMask = CSL_MCBSP_CTRL_RX_DISABLE
                | CSL_MCBSP_CTRL_TX_DISABLE
                | CSL_MCBSP_CTRL_FSYNC_DISABLE   //GAI
                | CSL_MCBSP_CTRL_SRG_DISABLE;       //GAI(5-22 9:16)
     CSL_mcbspHwControl (hMcbsp, CSL_MCBSP_CMD_RESET_CONTROL, &ctrlMask);
     WAIT_FOR_2_CLK;
  status = CSL_mcbspHwSetupRaw (hMcbsp, &MyConfig);
  WAIT_FOR_2_CLK;

  WAIT_FOR_2_CLK;
  ctrlMask =0;
 hMcbsp->regs->SPCR =0x02E01000;//GRST=1
  WAIT_FOR_2_CLK;
 hMcbsp->regs->SPCR =0x02401000;
  WAIT_FOR_2_CLK;
 hMcbsp->regs->SPCR =0x02411001;//XRST=RRST=1
  WAIT_FOR_2_CLK;
}
void  DSP_MCBSP_Write()
{
 int a=5;
  while(1)
  {
          CSL_mcbspWrite (hMcbsp, CSL_MCBSP_WORDLEN_8, &a);

     }
}
void main()
{
 //int a;
 DSP_MCBSP_Init();
 DSP_MCBSP_Write();
}


 

  • Yue Zhang,

    Your DSP_MCBSP_Write() cannot be from a working example. Please find a working example of the use of the McBSP to use as a starting point for your test program.

    This may show you the correct sequence for many of the settings in your DSP_MCBSP_Init() function, also.

    Regards,
    RandyP

  • thank you for the answer, but i'm not really understand your answer, first of all, what's in the DSP_MCBSP_Write() is found from the example of CSL although the example is used for normal MCBSP instead of SPI.

    secondly, as i said, when i close the GRST in SPCR register, others remain the same, i can get the signle ,and the DX is what i write in DSP_MCBSP_Write()(5 in this example), the problem is when i specified frequency(set the GRST as 1 to enable the SRGR register), i can get no signle.

    last, i have no idea what  the working example in your reply mean and can you offer me some example? THANK YOU !

    Regards,

    Zhang


  • Zhang,

    When I said "working example", I meant an example from the CSL. Which example of CSL did you use to start your application?

    I cannot understand why any working example would use only a while (1) loop around the CSL_mcbspWrite() function, so I have doubts about the rest of the code, also. Please tell me exactly what you started with and whether you were able to run that example and see proper behavior.

    Regards,
    RandyP

  • RandyP

    my TMS320SEVM6457 was producted by einfochip company, and there was a CD in the box which contant the CSL of the board. in the CSL example i cannot find the exactly SPI code, but there are three example of MCBSP which show as follow picture, and i refer to the single channel code because i only need single channel, but i only use some of the code like

     CSL_mcbspHwControl (hMcbsp, CSL_MCBSP_CMD_RESET_CONTROL, &ctrlMask);

     and the  fuction of CSL_mcbspHwSetupRaw (hMcbsp, &MyConfig) from the very begining is write by myself. the while(1) is also write by myself, all i want to do is keep the spi in the dead loop which it can always transmit the code writen in the CSL_mcbspWrite() and i can get continual behavior. as i said, when i close the GRST, i can get proper behavior on  the OSC, but when i set GRST as 1, i get nothing. i wonder if you can check the register is configured right or not in my code?

    hope for your reply!

    Regards,

    zhang

  • Zhang,

    Why is the name blacked out in your reply above? I am not providing the level of support you require.

    To allow others better understanding of your code, the examples from eInfoChips and TI use symbolic constants that allow a reader such as myself to understand the bit definitions and settings. It is impractical and easy to fail when asking someone else to decode hex values. You know very well what the bit settings are that you chose for your code, but a new reader does not know that as well as you, and your use of symbolic bit-field constants make the task of supporting you easier or practical.

    The combined procedures for initialization are described in the McBSP User Guide and must be followed. This includes the General Initialization Procedure and the McBSP Initialization for SPI Mode. For example, the General Initialization Procedure specifies in detail the proper use of GRST during initialization, and the McBSP Initialization for SPI Mode does not include as much detail but only says when to bring GRST=1; GRST must still be set to 0 at the appropriate time.

    Please measure the time duration of the WAIT_FOR_2_CLK macro in your code. The duration of this macro will vary based on the relative speeds of your DSP clock and your bit clocks, and it will vary based on your compiler version and compiler settings. Please confirm that the proper delays are reached as specified in the McBSP User Guide initialization procedures. I see that this same macro was used in our example, and we can assume it worked for specific cases as they used it, but we cannot assume it will always work for every use of the macro and the McBSP.

    Perhaps someone will join the discussion to provide the proper level of service.

    Regards,
    RandyP

  • RandyP

    i'm really sorry for your name blacked out, it's wrong by font setting, and i really appreciate your patient to answer my question. i'm a new user so have a few knowledge for DSP, anyway, i will try to figure it out with your suggestion, if i meet some other problem, i hope to find answer from you. Again i'm really thankful for your help!