DSP28335 MCBSP调试程序

DSP28335 MCBSP调试程序


2024年1月12日发(作者:)

DSP28335 MCBSP调试程序源码

本程序使用MCBSPB,GPIO24,GPIO25,GPIO26,GPIO60。时钟停止模式,发送时钟内部输出,接收时钟外部提供。中断接收。8位数据。测试时,可短接收发输出IO和收发时钟IO。

void InitMcbsp(void)

{

}

void InitMcbspb_DMA(void)//MSP初始化

{

= 1; // CLKSM=1 (If SCLKME=0, i/p

= 1;

= 0;

// CLKX generated internally, CLKR

//输入时钟由外部时钟驱动

derived from an external source

= 1;

= 1;

// FSX generated internally, FSR

derived from an external source

=0x0;

=0x0;

// Single-phase frame, 1 word/frame,

No companding (Transmit)

=0x0;

=0x0;

// Single-phase frame, 1 word/frame,

No companding (Receive)

= 0; // Enable DLB mode. Comment out for

= 2; //使能时钟停止模式

non-DLB mode.是否内部连接DX与DR

=0x0000;

=0x0000;

=0x0;

// Reset FS generator, sample rate

// Reset Receiver, Right justify word

// Disable all interrupts

generator & transmitter

//InitMcbspa();

//#if DSP28_MCBSPB

InitMcbspbGpio();

InitMcbspb_DMA();

//#endif // end DSP28_MCBSPB

clock to SRG is LSPCLK),=1表示MCBSP时钟由CPU提供

}

void InitMcbspb8bit(void)

{

1=0; // 8-bit word

1=0; // 8-bit word

}

void InitMcbspbGpio(void)

{

EALLOW;

/* Configure McBSP-A pins using GPIO regs*/

// This specifies which of the possible GPIO pins will be McBSP functional

pins.

// Comment out other unwanted lines.

//12 = 3; // GPIO12 is MDXB pin (Comment as

24 = 3; // GPIO24 is MDXB pin (Comment as

needed)

needed)

//=0;

//Enable Sample rate generator

=1; // 采样率时钟发生器复位停止

delay_loop(); // Wait at least 2 SRG clock cycles

=1; // Release TX from Reset

=1; // Release RX from Reset

delay_loop();

=1; // Frame Sync Generator reset

= 0; // Enable Transmit Interrupts

= 1; // Enable Receive Interrupts

// Initialize McBSP Data Length

InitMcbspb8bit();

= 0;

= 0; // Frame Width = 1 CLKG period,帧同 = 149; // CLKG frequency =

步脉冲宽度

LSPCLK/(CLKGDV+1),时钟设置,LSPCLK=37.5MHZ

= 15; // FPER = 32 CLKG periods,帧同步信号间隔

//13 = 3; // GPIO13 is MDRB pin (Comment as

25 = 3; // GPIO25 is MDRB pin (Comment as

//14 = 3; // GPIO14 is MCLKXB pin (Comment

26 = 3; // GPIO26 is MCLKXB pin (Comment

//3 = 3; // GPIO3 is MCLKRB pin

needed)

needed)

as needed)

as needed)

(Comment as needed)

60 = 1; // GPIO60 is MCLKRB pin (Comment

//15 = 3; // GPIO15 is MFSXB pin (Comment

27 = 3; // GPIO27 is MFSXB pin (Comment

//1 = 3; // GPIO1 is MFSRB pin

as needed)

as needed)

as needed)

(Comment as needed)

61 = 1; // GPIO61 is MFSRB pin (Comment

as needed)

/* Enable internal pull-up for the selected pins */

// Pull-ups can be enabled or disabled by the user.

// This will enable the pullups for the specified pins.

// Comment out other unwanted lines.

24 = 0; // Enable pull-up on GPIO24

(MDXB) (Comment as needed)

//12 = 0; // Enable pull-up on GPIO12

25 = 0; // Enable pull-up on GPIO25

(MDXB) (Comment as needed)

(MDRB) (Comment as needed)

//13 = 0; // Enable pull-up on GPIO13

26 = 0; // Enable pull-up on GPIO26

(MDRB) (Comment as needed)

(MCLKXB) (Comment as needed)

//14 = 0; // Enable pull-up on GPIO14

//3 = 0; // Enable pull-up on GPIO3

60 = 1;

27 = 0;

// Enable pull-up on GPIO60

(MCLKXB) (Comment as needed)

(MCLKRB) (Comment as needed)

(MCLKRB) (Comment as needed)

// Enable pull-up on GPIO27

(MFSXB) (Comment as needed)

//15 = 0; // Enable pull-up on GPIO15

(MFSXB) (Comment as needed)

/* Set qualification for selected pins to asynch only */

// This will select asynch (no qualification) for the selected pins.

// Comment out other unwanted lines.

24 = 3; // Asynch input GPIO24 (MDXB)

(Comment as needed)

//12 = 3; // Asynch input GPIO12 (MDXB)

(Comment as needed)

25 = 3; // Asynch input GPIO25 (MDRB)

(Comment as needed)

//13 = 3; // Asynch input GPIO13 (MDRB)

(Comment as needed)

26 = 3; // Asynch input GPIO26(MCLKXB)

(Comment as needed)

//14 = 3; // Asynch input GPIO14 (MCLKXB)

(Comment as needed)

//3 = 3; // Asynch input GPIO3 (MCLKRB)

(Comment as needed)

60 = 3; // Asynch input GPIO60 (MCLKRB)

(Comment as needed)

27 = 3; // Asynch input GPIO27 (MFSXB)

(Comment as needed)

}

void McBSPB_TXdata(Uint16 *data,Uint16 number)

{

Uint16 i=0;

for(i=0;i

{

=data[i] & 0x00FF;

EDIS;

//15 = 3; // Asynch input GPIO15 (MFSXB)

//1 = 3; // Asynch input GPIO1 (MFSRB)

61 = 3; // Asynch input GPIO61 (MFSRB)

(Comment as needed)

(Comment as needed)

(Comment as needed)

//1 = 0; // Enable pull-up on GPIO1

61 = 0; // Enable pull-up on GPIO61

(MFSRB) (Comment as needed)

(MFSRB) (Comment as needed)

}

}

while(!);

void delay_loop(void)

{

long i;

for (i = 0; i < MCBSP_INIT_DELAY; i++) {} //delay in McBsp init. must

be at least 2 SRG cycles

}

void clkg_delay_loop(void)

{

long i;

for (i = 0; i < MCBSP_CLKG_DELAY; i++) {} //delay in McBsp init. must

be at least 2 SRG cycles

}

Main函数初始化

void main(void)

{

InitSysCtrl(); //初始化系统控制

//正常情况下占用N+1个时钟周期

//屏蔽全局中断

//初始化PIE控制器

//

//初始化PIE中断向量表

asm(" RPT #8 || NOP");

DINT;

InitPieCtrl();

IER = 0x0000;

IFR = 0x0000;

InitPieVectTable();

asm(" RPT #8 || NOP");

//InitCpuTimers();

//ConfigCpuTimer(&CpuTimer0, 150, 10000); //0.01s

//InitGpio();

//InitAdc();

//InitI2C();

//StartDMACH1();

//StartDMACH2();

InitMcbsp();

0 = &cpu_timer0_isr;

//1_INT = &epwm1_isr;

//1 = &ADCINT_ISR;

//NTA=&SPIRXINTA_ISR;

//NTC=&SCIRXINTB_ISR;

//进行数据采集

EALLOW;

//InitXintf();

//InitScic();

= &MRINTB_ISR;

//= &MXINTB_ISR;

//= &MRINTA_ISR;

//= &MXINTA_ISR;

1= &DINTCH1_ISR;//DMA

2= &DINTCH2_ISR;//DMA

EDIS;

= 1;

7 = 1;

//开CPU定时器中断

//4 = 1; //AD7606中断

//1 = 0; //SPI接收中断

//5 = 0; //SCI接收中断

//1 = 1; //

3=1; // Enable PIE Group 6, INT 3

4=1; // Enable PIE Group 6, INT 4

5=1; // Enable PIE Group 6, INT 5

6=1; // Enable PIE Group 6, INT 6

1=1;

CH1)

2=1;

CH2)

IER |= (M_INT1 | M_INT3 | M_INT6 | M_INT7);

EINT; // Enable Global interrupt INTM

ERTM; // Enable Global realtime interrupt DBGM。调试仿真器实时状态下访问内存或寄存器

//StartCpuTime0();

// Enable PIE Group 7, INT 2 (DMA

// Enable PIE Group 7, INT 1 (DMA

////////////////EEPROM读写函数/////////////////////

while(1)

{

}

}

中断函数:

interrupt void MRINTB_ISR(void) // McBSP-B

{

}

可正常实现收发测试

mcbsp_rx[i]=;

i++;

if(i==16)

{

}

// To receive more interrupts from this PIE group, acknowledge this

= PIEACK_GROUP6;

//asm (" ESTOP0");

//for(;;);

i=0;

/*while(_SEQ1 == 0){}

_SEQ1_CLR = 1;

ADC_Result[0]=(ULT0)>>4;

ADC_Result[1]=(ULT1)>>4;

ADC_Result[2]=(ULT2)>>4;

ADC_Result[3]=(ULT3)>>4;

ADC_Result[4]=(ULT4)>>4;

ADC_Result[5]=(ULT5)>>4;

ADC_Result[6]=(ULT6)>>4;

ADC_Result[7]=(ULT7)>>4;*/

McBSPB_TXdata(mcbsp_tx,16);

//WriteData(dat,0x00,8);

//DELAY_US(10000);

//ReadData(dat1,0x05,8);

interrupt


发布者:admin,转转请注明出处:http://www.yc00.com/web/1705056481a1389395.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信