DSPRelated.com
Forums

C6713 ADC Code- Help Needed

Started by B S May 18, 2010
Hi,

I have to sample a real time analog signal for my application, I have seen the sampling example for C6713 but couldn't get much of it. Can any one please provide me simple code for sampling 1KHz sinewave using C6713 ADC ?

Thanks.
Kind of scratching my head on this one...

What do you mean by not "getting much of it"? I'm also making the assumption that you're talking about the C6713 DSK board, as opposed to some other C6713 platform.

It's been awhile, but from what I recall, the example digitization examples are fairly straightforward, and simply amount to setting up the McBSP (and EDMA is you're using EDMA, or just just polling), and then gathering the data.

You might want to fill out a little bit more details  - maybe showing the example code, describing any compile or link errors (if that's what's happening) - describe the steps you are taking and the resulting problems with more detail. That way there is a better chance that someone might be able to help.

Just a humble suggestion.
--- On Tue, 5/18/10, B S wrote:

From: B S
Subject: [c6x] C6713 ADC Code- Help Needed
To: c...
Date: Tuesday, May 18, 2010, 8:33 AM

 





Hi,

I have to sample a real time analog signal for my application, I have seen the sampling example for C6713 but couldn't get much of it. Can any one please provide me simple code for sampling 1KHz sinewave using C6713 ADC ?

Thanks.












_____________________________________
B S,

You state that you already have example code on how to sample a received signal.

Are you saying that you do not understand the code?

If you post that code and indicate which parts you are not understanding; then we could help you.

R. Williams

---------- Original Message -----------
From: B S
To: c...
Sent: Tue, 18 May 2010 06:33:10 -0700 (PDT)
Subject: [c6x] C6713 ADC Code- Help Needed

>
>
> Hi,
>
> I have to sample a real time analog signal for my application, I have seen the sampling example for C6713 but couldn't get much of it. Can any one please provide me simple code for sampling 1KHz sinewave using C6713 ADC ?
>
> Thanks.
------- End of Original Message -------
Hi,

I am actually a Matlab guy, didn't have any prior knowledge
of writing or encountering embedded C progamming so kind of difficult
for me to understand whats going on there. I don't know George what
digitization example are you talking about but I am talking about dsk_app.pjt program shipped by TI with the C6713 development kit. The DSK_App example digitally processes
audio data from the line input on the AIC23 codec and plays the result
on the headphone and line output. There are two .c files in the
project, one is aic23.c and other one is dsk_app.c, I don't know if
aic23.c is the code I am looking for to sample my analog signal, I also
couldn't found where sampling frequenc has been set in this code.

Following is the piece of aic23.c code. R. Willaims, if you could help me understand this code.

* AIC23 codec driver implementation specific to the
* Spectrum
Digital DSK6713 board.
*/

#include "dsk_appcfg.h"

#include

#include
#include


static void aic23Rset(MCBSP_Handle hMcbsp,
Uint16 regnum, Uint16 regval);

/* CSL handle to the McBSP0. The
McBSP is used as the control channel in SPI*/
static MCBSP_Config
mcbspCfg0 = {
MCBSP_FMKS(SPCR, FREE, NO) |
MCBSP_FMKS(SPCR, SOFT, NO) |
MCBSP_FMKS(SPCR,
FRST, YES) |
MCBSP_FMKS(SPCR, GRST, YES) |
MCBSP_FMKS(SPCR, XINTM, XRDY) |
MCBSP_FMKS(SPCR,
XSYNCERR, NO) |
MCBSP_FMKS(SPCR, XRST,
YES) |
MCBSP_FMKS(SPCR, DLB, OFF) |
MCBSP_FMKS(SPCR, RJUST, RZF) |
MCBSP_FMKS(SPCR, CLKSTP, NODELAY) |

MCBSP_FMKS(SPCR, DXENA, OFF) |
MCBSP_FMKS(SPCR,
RINTM, RRDY) |
MCBSP_FMKS(SPCR, RSYNCERR,
NO) |
MCBSP_FMKS(SPCR, RRST, YES),

MCBSP_FMKS(RCR, RPHASE, DEFAULT) |
MCBSP_FMKS(RCR,
RFRLEN2, DEFAULT) |
MCBSP_FMKS(RCR, RWDLEN2, DEFAULT) |
MCBSP_FMKS(RCR, RCOMPAND, DEFAULT) |
MCBSP_FMKS(RCR, RFIG, DEFAULT) |
MCBSP_FMKS(RCR,
RDATDLY, DEFAULT) |
MCBSP_FMKS(RCR, RFRLEN1,
DEFAULT) |
MCBSP_FMKS(RCR, RWDLEN1, DEFAULT) |
MCBSP_FMKS(RCR, RWDREVRS, DEFAULT),

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

MCBSP_FMKS(SRGR, GSYNC,
FREE) |
MCBSP_FMKS(SRGR, CLKSP, RISING) |
MCBSP_FMKS(SRGR, CLKSM, INTERNAL) |
MCBSP_FMKS(SRGR,
FSGM, DXR2XSR) |
MCBSP_FMKS(SRGR, FPER,
OF(0)) |
MCBSP_FMKS(SRGR, FWID, OF(19)) |
MCBSP_FMKS(SRGR, CLKGDV, OF(99)),

MCBSP_MCR_DEFAULT,

MCBSP_RCER_DEFAULT,
MCBSP_XCER_DEFAULT,

MCBSP_FMKS(PCR, XIOEN, SP) |
MCBSP_FMKS(PCR,
RIOEN, SP) |
MCBSP_FMKS(PCR, FSXM,
INTERNAL) |
MCBSP_FMKS(PCR, FSRM, EXTERNAL) |
MCBSP_FMKS(PCR, CLKXM, OUTPUT) |
MCBSP_FMKS(PCR, CLKRM, INPUT) |

MCBSP_FMKS(PCR, CLKSSTAT, DEFAULT) |
MCBSP_FMKS(PCR,
DXSTAT, DEFAULT) |
MCBSP_FMKS(PCR, FSXP,
ACTIVELOW) |
MCBSP_FMKS(PCR, FSRP, DEFAULT) |
MCBSP_FMKS(PCR, CLKXP, FALLING) |
MCBSP_FMKS(PCR,
CLKRP, DEFAULT)
};

/*
* ======== AIC23_setParams ======= *
* This function takes a pointer to the object of type AIC23_Params,
* and writes all 11 control words found in it to the codec. Prior
* to that it initializes the codec if this is the first time the
* function is ever called.
*
The 16-bit word is composed of register address in the upper 7 bits
* and the 9-bit register value stored in the parameters structure.
*/
Void AIC23_setParams(AIC23_Params *params)
{
Int i;

MCBSP_Handle hMcbsp;

/* open and configure McBSPs */

hMcbsp = MCBSP_open(MCBSP_PORT0, MCBSP_OPEN_RESET);

MCBSP_config(hMcbsp, &mcbspCfg0);

/*
*
Initialize the AIC23 codec
*/

/* Start McBSP1 as the
codec control channel */
MCBSP_start(hMcbsp, MCBSP_XMIT_START |
MCBSP_SRGR_START |
MCBSP_SRGR_FRAMESYNC, 100);

/* Reset the AIC23 */

aic23Rset(hMcbsp, AIC23_RESET, 0);

/* Assign each
register */
for (i = 0; i < AIC23_NUMREGS; i++) {

aic23Rset(hMcbsp, i, params->regs[i]);
}
}
/*
* ======== aic23Rset ======= * Set codec register regnum to value
regval
*/
static Void aic23Rset(MCBSP_Handle hMcbsp, Uint16
regnum, Uint16 regval)
{
/* Mask off lower 9 bits */

regval &= 0x1ff;

/* Wait for XRDY signal before
writing data to DXR */
while (!MCBSP_xrdy(hMcbsp));

/* Write 16 bit data value to DXR */
MCBSP_write(hMcbsp, (regnum << 9) | regval);

/* Wait for XRDY, state machine will not update until next McBSP clock
*/
while (MCBSP_xrdy(hMcbsp));
}

Regards..

________________________________
From: Richard Williams
To: B S ; c...
Sent: Tue, May 18, 2010 6:34:14 PM
Subject: Re: [c6x] C6713 ADC Code- Help Needed

B S,

You state that you already have example code on how to sample a received signal.

Are you saying that you do not understand the code?

If you post that code and indicate which parts you are not understanding; then we could help you.

R. Williams

---------- Original Message
-----------
From: B S
To: c6x@yahoogroups. com
Sent: Tue, 18 May 2010 06:33:10 -0700 (PDT)
Subject: [c6x] C6713 ADC Code- Help Needed

>
>
> Hi,
>
> I have to sample a real time analog
signal for my application, I have seen the sampling example for C6713 but
couldn't get much of it. Can any one please provide me simple code for sampling
1KHz sinewave using C6713 ADC ?
>
> Thanks.
------- End of Original Message
-------

_____________________________________