DSPRelated.com
Forums

Using McBSP as I/O

Started by ahma...@yahoo.com December 12, 2005
hi
I have written the following program for dsk6711 to use McBSP1 as I/O; but when I debug the program by putting a break point at the end or middle of the for loop,the content of input buffers (like FSRP) don't change although I change the logical level of the corresponding input pins. In other word the program read input pins only once in my program. Why?
Please help me.
thanks my program is:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <csl_timer.h>
/*----*/
/* DSP/BIOS includes */
/*----*/

/*----*/
//extern far LOG_Obj LogMain;
#include <std.h>
#include <log.h>
#include <swi.h>
#include <sem.h>
#include <clk.h>

/*----*/
/* CSL includes */
/*----*/

#include <csl.h>
#include <csl_irq.h>
#include <csl_dat.h>
#include <csl_cache.h>
#include <csl_mcbsp.h>

/*----*/
/* Application includes */
/*----*/

#include "vcap.h"
#include "vdis.h"
#include "img_proc.h" #pragma DATA_SECTION(ext_mem,".image:ext_sect");
#pragma DATA_SECTION(int_mem,".chip_image:int_sect");
#pragma DATA_ALIGN(ext_mem,8);
#pragma DATA_ALIGN(int_mem, 8);

unsigned char ext_mem[2*576 * 769];
unsigned char int_mem[64000];
static MCBSP_Config ConfigLoopback = {
0x000,
/* MCBSP_SPCR_RMK(
MCBSP_SPCR_FREE_YES,
MCBSP_SPCR_SOFT_YES,
MCBSP_SPCR_FRST_YES,
MCBSP_SPCR_GRST_YES,
MCBSP_SPCR_XINTM_XRDY,
MCBSP_SPCR_XSYNCERR_NO,
MCBSP_SPCR_XRST_YES,
MCBSP_SPCR_DLB_ON,
MCBSP_SPCR_RJUST_RZF,
MCBSP_SPCR_CLKSTP_DISABLE,
MCBSP_SPCR_DXENA_OFF,
MCBSP_SPCR_RINTM_RRDY,
MCBSP_SPCR_RSYNCERR_NO,
MCBSP_SPCR_RRST_YES
),*/
0x000,
/*
MCBSP_RCR_RMK(
MCBSP_RCR_RPHASE_SINGLE,
MCBSP_RCR_RFRLEN2_OF(0),
MCBSP_RCR_RWDLEN2_8BIT,
MCBSP_RCR_RCOMPAND_MSB,
MCBSP_RCR_RFIG_YES,
MCBSP_RCR_RDATDLY_0BIT,
MCBSP_RCR_RFRLEN1_OF(0),
MCBSP_RCR_RWDLEN1_32BIT,
MCBSP_RCR_RWDREVRS_DISABLE
),*/
0x00000,
/*
MCBSP_XCR_RMK(
MCBSP_XCR_XPHASE_SINGLE,
MCBSP_XCR_XFRLEN2_OF(0),
MCBSP_XCR_XWDLEN2_8BIT,
MCBSP_XCR_XCOMPAND_MSB,
MCBSP_XCR_XFIG_YES,
MCBSP_XCR_XDATDLY_0BIT,
MCBSP_XCR_XFRLEN1_OF(0),
MCBSP_XCR_XWDLEN1_32BIT,
MCBSP_XCR_XWDREVRS_DISABLE
),*/
0x33fc05ff,
/*
MCBSP_SRGR_RMK(
MCBSP_SRGR_GSYNC_FREE,
MCBSP_SRGR_CLKSP_RISING,
MCBSP_SRGR_CLKSM_INTERNAL,
MCBSP_SRGR_FSGM_DXR2XSR,
MCBSP_SRGR_FPER_OF(63),
MCBSP_SRGR_FWID_OF(31),
MCBSP_SRGR_CLKGDV_OF(15)
),*/
0x0,
/*
MCBSP_MCR_DEFAULT,*/
0x0,
/*
MCBSP_RCER_DEFAULT,*/
0x0,
/*
MCBSP_XCER_DEFAULT,*/
0x1000
/*
MCBSP_PCR_RMK(
MCBSP_PCR_XIOEN_SP,
MCBSP_PCR_RIOEN_SP,
MCBSP_PCR_FSXM_INTERNAL,
MCBSP_PCR_FSRM_EXTERNAL,
MCBSP_PCR_CLKXM_OUTPUT,
MCBSP_PCR_CLKRM_INPUT,
MCBSP_PCR_CLKSSTAT_0,
MCBSP_PCR_DXSTAT_0,
MCBSP_PCR_FSXP_ACTIVEHIGH,
MCBSP_PCR_FSRP_ACTIVEHIGH,
MCBSP_PCR_CLKXP_RISING,
MCBSP_PCR_CLKRP_FALLING
)*/
};

void main()
{
MCBSP_Handle hMcbsp;
TIMER_Handle hTimer;
volatile Uint32 x,y;
Uint32 PinMask;
int success = 1;
/*-*/
/* Flush the cache for all contents */
/*-*/

CACHE_flush(CACHE_L2ALL,0,0); /*--*/
/* Initialize the CSL library */
/*--*/

CSL_init();

/* Let's open up serial port 1 */
hMcbsp = MCBSP_open(MCBSP_DEV1, MCBSP_OPEN_RESET);

/* We'll set it up for digital loopback, 32bit mode. We have */
/* to setup the sample rate generator to allow self clocking. */
MCBSP_config(hMcbsp,&ConfigLoopback);

MCBSP_start(hMcbsp,MCBSP_RCV_START | MCBSP_XMIT_START | MCBSP_SRGR_START| MCBSP_SRGR_FRAMESYNC, MCBSP_SRGR_DEFAULT_DELAY);

/* Now we'll write our program.*/

y=0;
for (x=0;x<10000;x++){
PinMask = MCBSP_getPins(hMcbsp); if (PinMask & MCBSP_PIN_CLKR)
{
y=y+1;
}

}
PinMask = MCBSP_getPins(hMcbsp);
/* All done now, close the port. */
MCBSP_close(hMcbsp); }

/*----*/

/******************************************************************************\
* End of main.c
\******************************************************************************/