dsp 2812 xintf的xd和xa 如何 *** 作

dsp 2812 xintf的xd和xa 如何 *** 作,第1张

#define SetData GpioDataRegs.GPFDAT.bit.GPIOF0 = 1

#define ClrData GpioDataRegs.GPFDAT.bit.GPIOF0 = 0

#define SetClk GpioDataRegs.GPFDAT.bit.GPIOF2 = 1

#define ClrClk GpioDataRegs.GPFDAT.bit.GPIOF2 = 0

unsigned int * LedReg = (unsigned int *) 0x23FF

unsigned int * Led8Lock= (unsigned int *) 0x25FF

这段程序有几个作用:

-宏SetData和ClrData:目的是通过设置GPIO的数据寄存器,将管脚40的输出设置成高或低,由于你原理图没有这个管脚不知道是用于什么方向的;

-宏SetClk和ClrClk:类似上一个,是将管脚34设置成高或低,上个管脚是GPIOF0,这个是GPIOF2

-在访问有关Led的寄存器时,用的地址是0x23FF,XA总线将会出这个地址,访问这个地址将会在44脚出CS1,不知道CS1除了接U23_1外还接到了哪里,应当是 *** 作CS1选通的设备了(图中没有,U23_1出的Y0也没有接)

-在访问Led8的锁存寄存器时,用的地址是0x25FF,首先管脚44会出信号CS1,经U23_1后会得到mCS_LED573信号,会给U23_2的锁存信号,将数据D7~D0锁存到供U23的8个段状态的管脚,比如*Led8Lock=0xFF将使FF锁存到U23的管脚2~5、7~10,导致数码管8个LED全部熄灭。

这是 DSP28335的例程,程序目的是通过按不同的按键,通过中断改变LED的闪动方式

,你可以对比一下。 (DSP2812和 DSP28335是差不多的)

#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File#include "DSP2833x_Examples.h" // DSP2833x Examples Include File

#define LED1_ON GpioDataRegs.GPASET.bit.GPIO0=1

#define LED1_OFF GpioDataRegs.GPACLEAR.bit.GPIO0=1

#define LED2_ON GpioDataRegs.GPASET.bit.GPIO1=1

#define LED2_OFF GpioDataRegs.GPACLEAR.bit.GPIO1=1

#define LED3_ON GpioDataRegs.GPASET.bit.GPIO2=1

#define LED3_OFF GpioDataRegs.GPACLEAR.bit.GPIO2=1

#define LED4_ON GpioDataRegs.GPASET.bit.GPIO3=1

#define LED4_OFF GpioDataRegs.GPACLEAR.bit.GPIO3=1

#define LED5_ON GpioDataRegs.GPASET.bit.GPIO4=1

#define LED5_OFF GpioDataRegs.GPACLEAR.bit.GPIO4=1

#define LED6_ON GpioDataRegs.GPASET.bit.GPIO5=1

#define LED6_OFF GpioDataRegs.GPACLEAR.bit.GPIO5=1

#define LED7_ON GpioDataRegs.GPBSET.bit.GPIO51=1

#define LED7_OFF GpioDataRegs.GPBCLEAR.bit.GPIO51=1

#define LED8_ON GpioDataRegs.GPBSET.bit.GPIO50=1

#define LED8_OFF GpioDataRegs.GPBCLEAR.bit.GPIO50=1

interrupt void ISRExint3(void)

interrupt void ISRExint4(void)

interrupt void ISRExint5(void)

interrupt void ISRExint6(void)

void configtestled(void)

Uint16 sign

void main(void)

{

// Step 1. Initialize System Control:

// PLL, WatchDog, enable Peripheral Clocks

// This example function is found in the DSP2833x_SysCtrl.c file.

InitSysCtrl()

// Step 2. Initalize GPIO:

// This example function is found in the DSP2833x_Gpio.c file and

// illustrates how to set the GPIO to it's default state.

// InitGpio() // Skipped for this example

InitXintf16Gpio()//zq

// Step 3. Clear all interrupts and initialize PIE vector table:

// Disable CPU interrupts

DINT

// Initialize the PIE control registers to their default state.

// The default state is all PIE interrupts disabled and flags

// are cleared.

// This function is found in the DSP2833x_PieCtrl.c file.

InitPieCtrl()

// Disable CPU interrupts and clear all CPU interrupt flags:

IER = 0x0000

IFR = 0x0000

// Initialize the PIE vector table with pointers to the shell Interrupt

// Service Routines (ISR).

// This will populate the entire table, even if the interrupt

// is not used in this example. This is useful for debug purposes.

// The shell ISR routines are found in DSP2833x_DefaultIsr.c.

// This function is found in DSP2833x_PieVect.c.

InitPieVectTable()

// Interrupts that are used in this example are re-mapped to// ISR functions found within this file.

EALLOW // This is needed to write to EALLOW protected registers

PieVectTable.XINT3 = &ISRExint3

PieVectTable.XINT4 = &ISRExint4

PieVectTable.XINT5 = &ISRExint5

PieVectTable.XINT6 = &ISRExint6

EDIS // This is needed to disable write to EALLOW protected registers

PieCtrlRegs.PIECTRL.bit.ENPIE = 1 // Enable the PIE block

PieCtrlRegs.PIEIER12.bit.INTx1= 1

PieCtrlRegs.PIEIER12.bit.INTx2= 1

PieCtrlRegs.PIEIER12.bit.INTx3= 1

PieCtrlRegs.PIEIER12.bit.INTx4= 1

IER |= M_INT12 // Enable CPU int1

EINT // Enable Global interrupt INTM

ERTM // Enable Global realtime interrupt DBGM

configtestled()

sign = 0

while(1)

{

if(sign==0)

{ LED1_OFF

LED2_OFF

LED3_OFF

LED4_OFF

LED5_OFF

LED6_OFF

LED7_OFF

LED8_OFF

DELAY_US(50000)

LED1_ON

DELAY_US(50000)

LED2_ON

DELAY_US(50000)

LED3_ON

DELAY_US(50000)

LED4_ON

DELAY_US(50000)

LED5_ON

DELAY_US(50000)

LED6_ON

DELAY_US(50000)

LED7_ON

DELAY_US(50000)

LED8_ON

DELAY_US(50000) //NO XINT

}

if(sign==3)

{

LED1_OFF

LED2_OFF

LED3_OFF

LED4_OFF

LED5_OFF

LED6_OFF

LED7_OFF

LED8_OFF

DELAY_US(50000)

LED1_ON

LED2_ON

DELAY_US(50000)

LED3_ON

LED4_ON

DELAY_US(50000)

LED5_ON

LED6_ON

DELAY_US(50000)

LED7_ON

LED8_ON

DELAY_US(50000) // XINT3 COME

}

if(sign==4)

{ LED1_ON

LED2_ON

LED3_ON

LED4_ON

LED5_ON

LED6_ON

LED7_ON

LED8_ON

DELAY_US(50000)

LED1_OFF

DELAY_US(50000)

LED2_OFF

DELAY_US(50000)

LED3_OFF

DELAY_US(50000)

LED4_OFF

DELAY_US(50000)

LED5_OFF

DELAY_US(50000)

LED6_OFF

DELAY_US(50000)

LED7_OFF

DELAY_US(50000)

LED8_OFF

DELAY_US(50000) // XINT4 COME

}

if(sign==5)

{LED1_ON

LED2_ON

LED3_ON

LED4_ON

LED5_ON

LED6_ON

LED7_ON

LED8_ON

DELAY_US(50000)

LED1_OFF

LED2_OFF

DELAY_US(50000)

LED3_OFF

LED4_OFF

LED1_ON

LED2_ON

DELAY_US(50000)

LED5_OFF

LED6_OFF

LED3_ON

LED4_ON

DELAY_US(50000)

LED7_OFF

LED8_OFF

LED5_ON

LED6_ON

DELAY_US(50000) // XINT5 COME

}

if(sign==6)

{LED1_OFF

LED2_ON

LED3_OFF

LED4_ON

LED5_OFF

LED6_ON

LED7_OFF

LED8_ON

DELAY_US(50000)

LED1_ON

LED2_OFF

LED3_ON

LED4_OFF

LED5_ON

LED6_OFF

LED7_ON

LED8_OFF

DELAY_US(50000) // XINT5 COME

}

}

}

interrupt void ISRExint3(void)

{

PieCtrlRegs.PIEACK.all = PIEACK_GROUP12

sign=3

}

interrupt void ISRExint4(void)

{

PieCtrlRegs.PIEACK.all = PIEACK_GROUP12

sign=4

}

interrupt void ISRExint5(void)

{

PieCtrlRegs.PIEACK.all = PIEACK_GROUP12

sign=5

}

interrupt void ISRExint6(void)

{

PieCtrlRegs.PIEACK.all = PIEACK_GROUP12

sign=6

}

void configtestled(void)

{

EALLOW

GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0// GPIO0 = GPIO0

GpioCtrlRegs.GPADIR.bit.GPIO0 = 1

GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0// GPIO1 = GPIO1

GpioCtrlRegs.GPADIR.bit.GPIO1 = 1

GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0// GPIO2 = GPIO2

GpioCtrlRegs.GPADIR.bit.GPIO2 = 1

GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0// GPIO3 = GPIO3

GpioCtrlRegs.GPADIR.bit.GPIO3 = 1

GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0// GPIO4 = GPIO4

GpioCtrlRegs.GPADIR.bit.GPIO4 = 1

GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 0// GPIO5 = GPIO5

GpioCtrlRegs.GPADIR.bit.GPIO5 = 1

GpioCtrlRegs.GPBMUX2.bit.GPIO51 = 0// GPIO51 = GPIO51

GpioCtrlRegs.GPBDIR.bit.GPIO51 = 1

GpioCtrlRegs.GPBPUD.bit.GPIO51=0

GpioCtrlRegs.GPBMUX2.bit.GPIO50 = 0// GPIO50 = GPIO50

GpioCtrlRegs.GPBDIR.bit.GPIO50 = 1

GpioCtrlRegs.GPBPUD.bit.GPIO50=0

EDIS

}

//===========================================================================

// No more.

//===========================================================================


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11520713.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存