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.

Mcbsp UART C613

Other Parts Discussed in Thread: MAX3232

Hello,

I am trying to configure one Mcbsp as UART and use the other for different purposes. I would like to communicate via Matlab. I have read SPRA633C thoroughly and it has been a great reference for transmitting via mcbsp. I can successfully transmit to matlab using the settings described in the app note. However, I have had some experience using the MCBSP_write( ) command and a DAC. On the side, I cannot receive data via the mcbsp. My setup is configured as follows.

The baud rate which I hope to T/R with is 115200 bps. (it works for transmit so far). This means I use a clock divide of 60 to generate the appropriate clock which is 16*baud. I write the corresponding bit values in 2 byte (16bit) packets. I am use a MAX3232 to convert the TTL signals to RS-232 and I have a prolific RS-232 cable for usb to serial communication. 

For receiving data I would assume the following format would apply as well. So, I use the FSYNC ignore setting and attempt to receive data in pretty much the same way I transmit. The frame sync is active low and tied to data RX. However, I notice that the MCBSP_read(hMcbsp1) returns a 32bit value. This seems alarming since I would ideally like it to be 16 bit packets like I transmit. With that being said I have tried just reading data and trying to make sense of it and have had no luck. I am sending my data from matlab serially and I am monitoring the data line which is fed into the DSK and I am sending a 32 bit ascii character to the board which I can see. It just seems like I am getting garbage on the receive end. My code for the c6713 is as follows.

Any help for reading the serial port would be appreciated.

Thanks,

Brady

______________________________________________________________________________

in the configuration I have:

______________________________________________________________________________

MCBSP_Config DAC_Control = {

MCBSP_FMKS(SPCR, FREE, YES) |
MCBSP_FMKS(SPCR, SOFT, DEFAULT) |
MCBSP_FMKS(SPCR, FRST, DEFAULT) |
MCBSP_FMKS(SPCR, GRST, DEFAULT) |
MCBSP_FMKS(SPCR, XINTM, XRDY) |
MCBSP_FMKS(SPCR, XSYNCERR, DEFAULT) |
MCBSP_FMKS(SPCR, XRST, DEFAULT) |
MCBSP_FMKS(SPCR, DLB, OFF) |
MCBSP_FMKS(SPCR, RJUST, RZF) |
MCBSP_FMKS(SPCR, CLKSTP, DISABLE) | 
MCBSP_FMKS(SPCR, DXENA, OFF) |
MCBSP_FMKS(SPCR, RINTM, RRDY) |
MCBSP_FMKS(SPCR, RSYNCERR, DEFAULT) |
MCBSP_FMKS(SPCR, RRST, DEFAULT), // 0 receiver disabled, 1 receiver enabled

MCBSP_FMKS(RCR, RPHASE, OF(1)) |
MCBSP_FMKS(RCR, RFRLEN2, OF(1)) |
MCBSP_FMKS(RCR, RWDLEN2, OF(0)) |
MCBSP_FMKS(RCR, RCOMPAND, OF(0)) |
MCBSP_FMKS(RCR, RFIG, OF(1)) |
MCBSP_FMKS(RCR, RDATDLY, 1BIT) |
MCBSP_FMKS(RCR, RFRLEN1, OF(8)) |
MCBSP_FMKS(RCR, RWDLEN1, OF(2)) |
MCBSP_FMKS(RCR, RWDREVRS, ENABLE),

MCBSP_FMKS(XCR, XPHASE, OF(1)) |
MCBSP_FMKS(XCR, XFRLEN2, OF(1)) |
MCBSP_FMKS(XCR, XWDLEN2, OF(0)) | 
MCBSP_FMKS(XCR, XCOMPAND, OF(0)) |
MCBSP_FMKS(XCR, XFIG, OF(1)) |
MCBSP_FMKS(XCR, XDATDLY, 0BIT) | 
MCBSP_FMKS(XCR, XFRLEN1, OF(8)) |
MCBSP_FMKS(XCR, XWDLEN1, OF(2)) | 
MCBSP_FMKS(XCR, XWDREVRS, DISABLE),

MCBSP_FMKS(SRGR, GSYNC, FREE) |
MCBSP_FMKS(SRGR, CLKSP, RISING) |
MCBSP_FMKS(SRGR, CLKSM, OF(1)) |
MCBSP_FMKS(SRGR, FSGM, OF(0)) |
MCBSP_FMKS(SRGR, FPER, OF(31)) | 
MCBSP_FMKS(SRGR, FWID, OF(0)) | 
MCBSP_FMKS(SRGR, CLKGDV, OF(60)), 

MCBSP_MCR_DEFAULT,
MCBSP_RCER_DEFAULT,
MCBSP_XCER_DEFAULT,

MCBSP_FMKS(PCR, XIOEN, SP) |
MCBSP_FMKS(PCR, RIOEN, SP) |
MCBSP_FMKS(PCR, FSXM, OF(1)) |
MCBSP_FMKS(PCR, FSRM, EXTERNAL) |
MCBSP_FMKS(PCR, CLKXM, OUTPUT) |
MCBSP_FMKS(PCR, CLKRM, OUTPUT) |
MCBSP_FMKS(PCR, CLKSSTAT, DEFAULT)|
MCBSP_FMKS(PCR, DXSTAT, DEFAULT) |
MCBSP_FMKS(PCR, FSXP, OF(1)) | 
MCBSP_FMKS(PCR, FSRP, OF(1)) |
MCBSP_FMKS(PCR, CLKXP, RISING) | 
MCBSP_FMKS(PCR, CLKRP, FALLING)
};
Int32 data[100] = {0};
MCBSP_Handle hMcbsp1;

______________________________________________________________________________

Configuring/Starting the mcbsp port

______________________________________________________________________________

/* connect McBSP1 to daughterboard interface */
*((unsigned char*)0x90080006) |= 0x03; // Set bits 0/1 of MISC CLPD reg, send McBSPx off board
//Set up the McBSP
hMcbsp1 = MCBSP_open(MCBSP_DEV0, MCBSP_OPEN_RESET);

MCBSP_config(hMcbsp1,&DAC_Control);

MCBSP_SRGR_FRAMESYNC, 0x0);

MCBSP_enableSrgr(hMcbsp1);
MCBSP_enableRcv(hMcbsp1);
MCBSP_enableXmt(hMcbsp1);
MCBSP_enableFsync(hMcbsp1);

______________________________________________________________________________

This is how I read and store the data:

______________________________________________________________________________

//code starts here

commandR = 1;

if(commandR){
     while(!MCBSP_rrdy(hMcbsp1));
     while(MCBSP_rrdy(hMcbsp1)){
          data[i] = MCBSP_read(hMcbsp1);
           i++;
     };
     printf("%d",MCBSP_rrdy(hMcbsp1));
     printf("%d\n",MCBSP_rfull(hMcbsp1));
};