TI中文支持网
TI专业的中文技术问题搜集分享网站

求助28377S 使用DMA的ADC程序 目标地址始终没有收到ADC数据

请忽略前面部分,直接看后面DMA部分,需要帮忙看的地方会有红字提示:

#include "F28x_Project.h"
#define res1 GPIO_WritePin(58, 1);
#define res0 GPIO_WritePin(58, 0);
#define sce1 GPIO_WritePin(59, 1);
#define sce0 GPIO_WritePin(59, 0);
#define dc1 GPIO_WritePin(72, 1);
#define dc0 GPIO_WritePin(72, 0);
#define sdin1 GPIO_WritePin(73, 1);
#define sdin0 GPIO_WritePin(73, 0);
#define sclk1 GPIO_WritePin(78, 1);
#define sclk0 GPIO_WritePin(78, 0);
Uint16 AdcaResult0;
Uint16 AdcaResult1;
volatile Uint16 *DMADest;
volatile Uint16 *DMASource;

unsigned char number[]={
0xF8,0x04,0x04,0x04,0xF8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x00,0x08,0xFC,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
0x18,0x84,0x44,0x24,0x18,0x00,0x03,0x02,0x02,0x02,0x02,0x00,
0x08,0x04,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x40,0xB0,0x88,0xFC,0x80,0x00,0x00,0x00,0x00,0x03,0x02,0x00,
0x3C,0x24,0x24,0x24,0xC4,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0xF8,0x24,0x24,0x2C,0xC0,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x0C,0x04,0xE4,0x1C,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0xD8,0x24,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x38,0x44,0x44,0x44,0xF8,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
//– . –10
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
//– –11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
unsigned char zimu[]={
/*– a 0–*/
0x00,0x40,0xA0,0xA0,0xC0,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
/*– b 1–*/
0x04,0xFC,0x20,0x20,0xC0,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
/*– c 2–*/
0x00,0xC0,0x20,0x20,0x60,0x00,0x00,0x01,0x02,0x02,0x02,0x00,
//– d 3–
0x00,0xC0,0x20,0x24,0xFC,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
//– e 4–
0x00,0xC0,0xA0,0xA0,0xC0,0x00,0x00,0x01,0x02,0x02,0x02,0x00,
//– f 5–
0x00,0x20,0xF8,0x24,0x24,0x04,0x00,0x02,0x03,0x02,0x02,0x00,
//– g 6–
0x00,0x40,0xA0,0xA0,0x60,0x20,0x00,0x07,0x0A,0x0A,0x0A,0x04,
//– h 7–
0x04,0xFC,0x20,0x20,0xC0,0x00,0x02,0x03,0x02,0x00,0x03,0x02,
//– i 8–
0x00,0x20,0xE4,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
//– j 9–
0x00,0x00,0x20,0xE4,0x00,0x00,0x08,0x08,0x08,0x07,0x00,0x00,
//– k 10–
0x04,0xFC,0x80,0xE0,0x20,0x20,0x02,0x03,0x02,0x00,0x03,0x02,
//– l 11–
0x04,0x04,0xFC,0x00,0x00,0x00,0x02,0x02,0x03,0x02,0x02,0x00,
//– m 12–
0xE0,0x20,0xE0,0x20,0xC0,0x00,0x03,0x00,0x03,0x00,0x03,0x00,
//– n 13–
0x20,0xE0,0x20,0x20,0xC0,0x00,0x02,0x03,0x02,0x00,0x03,0x02,
//– o 14–
0x00,0xC0,0x20,0x20,0xC0,0x00,0x00,0x01,0x02,0x02,0x01,0x00,
//– p 15–
0x20,0xE0,0x20,0x20,0xC0,0x00,0x08,0x0F,0x0A,0x02,0x01,0x00,
//– q 16–
0x00,0xC0,0x20,0x20,0xE0,0x00,0x00,0x01,0x02,0x0A,0x0F,0x08,
//– r 17–
0x20,0xE0,0x40,0x20,0x20,0x00,0x02,0x03,0x02,0x00,0x00,0x00,
//– s 18–
0x00,0x60,0xA0,0xA0,0x20,0x00,0x00,0x02,0x02,0x02,0x03,0x00,
//– t 19–
0x00,0x20,0xF8,0x20,0x00,0x00,0x00,0x00,0x01,0x02,0x02,0x00,
//– u 20–
0x20,0xE0,0x00,0x20,0xE0,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
//– v 21–
0x20,0xE0,0x20,0x80,0x60,0x20,0x00,0x00,0x03,0x01,0x00,0x00,
//– w 22–
0x60,0x80,0xE0,0x80,0x60,0x00,0x00,0x03,0x00,0x03,0x00,0x00,
//– x 23–
0x20,0x60,0x80,0x60,0x20,0x00,0x02,0x03,0x00,0x03,0x02,0x00,
//– y 24–
0x20,0xE0,0x20,0x80,0x60,0x20,0x08,0x08,0x07,0x01,0x00,0x00,
//– z 25–
0x00,0x20,0xA0,0x60,0x20,0x00,0x00,0x02,0x03,0x02,0x02,0x00,
//– . —
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
//– —
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//– _ —
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,
};
unsigned char hanzi[]=
{
0x00,0xFC,0x24,0x24,0x24,0xFF,0x24,0x24,
0x24,0xFE,0x04,0x00,0x00,0x01,0x01,0x01,
0x01,0x07,0x09,0x09,0x09,0x09,0x08,0x0E,//电 12*16
0x08,0x12,0xE4,0x00,0x12,0xD2,0x1A,0xD7,
0x12,0xDA,0x32,0x02,0x01,0x0F,0x00,0x08,
0x04,0x03,0x00,0x0F,0x00,0x07,0x08,0x0F,//流 12*16
0x00,0x00,0xFE,0x02,0x22,0x22,0xFA,0x22,
0xA2,0x32,0x23,0x02,0x0C,0x03,0x08,0x08,
0x08,0x08,0x0F,0x08,0x08,0x09,0x0A,0x08,//压 12*16
0x20,0x10,0xFC,0x03,0x02,0xFA,0xAA,0xAF,
0xAA,0xAA,0xFB,0x02,0x00,0x00,0x0F,0x00,
0x08,0x0F,0x0A,0x0A,0x0A,0x0A,0x0F,0x08,//值 12*16
0x00,0x00,0x8C,0x8C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //: 12*16
0x00,0x20,0xA4,0xA8,0xA0,0xBF,0xA0,0xB0,
0xA8,0xA6,0xF0,0x20,0x00,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0x04,0x0F,0x00,//当 12*16
0x04,0xF4,0x54,0x55,0x56,0xF4,0x04,0xF6,
0x05,0x04,0xF6,0x04,0x00,0x0F,0x01,0x01,
0x09,0x0F,0x00,0x03,0x04,0x08,0x07,0x00,//前 12*16
0x34,0x2C,0xF7,0xA4,0x10,0xE8,0xA4,0xEB,
0x0A,0xC4,0x08,0xE8,0x02,0x01,0x0F,0x00,
0x00,0x0F,0x02,0x0F,0x00,0x03,0x08,0x0F,//输 12*16
0x00,0x80,0x3E,0x10,0x10,0xFF,0x10,0x10,
0x10,0x3E,0x80,0x00,0x00,0x0F,0x04,0x04,
0x04,0x07,0x04,0x04,0x04,0x04,0x0F,0x00,//出 12*16
0x00,0x00,0x00,0x00,0x80,0x63,0x1C,0x60,
0x80,0x00,0x00,0x00,0x04,0x04,0x02,0x01,
0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x04,//入 12*16
0x10,0x11,0xF6,0x00,0x10,0x6F,0xA1,0x21,
0xA1,0x6F,0x10,0x10,0x00,0x00,0x07,0x0A,
0x09,0x04,0x05,0x02,0x05,0x04,0x08,0x08,//设 12*16
0x10,0x0C,0xD4,0x14,0x14,0xF5,0x96,0x94,
0xD4,0x94,0x04,0x0C,0x08,0x04,0x03,0x02,
0x04,0x07,0x08,0x08,0x08,0x08,0x08,0x08,//定 12*16
0x89,0xD2,0x20,0xFE,0x02,0xFA,0x02,0xFF,
0x02,0xFC,0x00,0xFF,0x00,0x0F,0x08,0x04,
0x02,0x01,0x02,0x04,0x00,0x05,0x08,0x07,//测 12*16
0x48,0x24,0xF2,0x09,0x40,0x5F,0x55,0x55,
0x55,0xD5,0x5F,0x40,0x00,0x00,0x0F,0x01,
0x01,0x01,0x07,0x01,0x09,0x0F,0x01,0x01,//得 12*16
};

void LCD_write_byte(unsigned char dt, unsigned char command)
{
unsigned char i;
sce0;
DELAY_US(5);
if(command==1)
{dc1;}
else {dc0;}
DELAY_US(5);
for(i=0;i<8;i++)
{
if(dt&0x80)
{sdin1;}
else
{sdin0;}
dt=dt<<1;
DELAY_US(5);
sclk0;
DELAY_US(5);
sclk1;
}
DELAY_US(5);
dc1;
DELAY_US(5);
sce1;
DELAY_US(5);
sdin1;
DELAY_US(5);
}
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40 | Y, 0);// column
LCD_write_byte(0x80 | X, 0);// row
}
void LCD_clear(void)
{
unsigned char t;
unsigned char k;
LCD_set_XY(0,0);
for(t=0;t<6;t++)
{
for(k=0;k<84;k++)
{
LCD_write_byte(0x00,1);
}
}
}
void LCD_Init()
{
GPIO_SetupPinMux(58, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(58, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(59, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(59, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(72, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(72, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(73, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(73, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(78, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(78, GPIO_OUTPUT, GPIO_PUSHPULL);
res0;
DELAY_US(1000);
res1;
LCD_write_byte(0x21,0);
LCD_write_byte(0xC4,0);//display contrast
LCD_write_byte(0x20,0);
LCD_write_byte(0x0C,0);
LCD_clear();
}
/*———————————————
8*16 number and alphabet
———————————————–*/
void LCD_write_alp(unsigned char row, unsigned char page,unsigned char c)
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<6;i++)
{
LCD_write_byte(zimu[c*12+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=6; i<12;i++)
{
LCD_write_byte(zimu[c*12+i],1);
}
}
void LCD_write_number(unsigned char row, unsigned char page,unsigned char c) //row:? page:? dd:??
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<6;i++)
{
LCD_write_byte(number[c*12+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=6; i<12;i++)
{
LCD_write_byte(number[c*12+i],1);
}
}
/*———————————————
12*16 hanzi
———————————————–*/
void LCD_write_hanzi(unsigned char row, unsigned char page,unsigned char c)
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<12;i++)
{
LCD_write_byte(hanzi[c*24+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=12; i<24;i++)
{
LCD_write_byte(hanzi[c*24+i],1);
}
}
void ConfigureADC(void)
{
EALLOW;

//write configurations
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

//Set pulse positions to late
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;

//power up the ADCs
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;

//delay for 1ms to allow ADC time to power up
DELAY_US(1000);

EDIS;
}
void SetupADCSoftware(void)
{
Uint16 acqps;

//determine minimum acquisition window (in SYSCLKS) based on resolution
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION){
acqps = 14; //75ns
}
else { //resolution is 16-bit
acqps = 63; //320ns
}

//Select the channels to convert and end of conversion flag
//ADCA
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin A1
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
}
void Trans_val(unsigned Hex_Val)
{
unsigned int Curr_Volt;
unsigned char ptr[4];

Curr_Volt = Hex_Val * 0.732422;

ptr[3]=Curr_Volt/1000;//x.000
ptr[2]=Curr_Volt%1000/100;//0.x00
ptr[1]=Curr_Volt%100/10;//0.0×0
ptr[0]=Curr_Volt%10;//0.00x

LCD_write_number(10,1,ptr[3]);
LCD_write_number(11,1,ptr[2]);
LCD_write_number(12,1,ptr[1]);
LCD_write_number(13,1,ptr[0]);
}

main()
{
InitSysCtrl();
InitGpio();
LCD_Init();

GPIO_SetupPinOptions(13, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(13, GPIO_MUX_CPU1, 0);

DINT;
IER = 0x0000;
IFR = 0x0000;

//Configure the ADCs and power them up
ConfigureADC();
//Setup the ADCs for software conversions
SetupADCSoftware();

以下是DMA的配置:

DMAInitialize();
DMADest = &AdcaResult0; //Point DMA destination to the beginning of the array
DMASource = &AdcaResultRegs.ADCRESULT0; //Point DMA source to ADC result register base
DMACH1AddrConfig(DMADest,DMASource);
DMACH1BurstConfig(1,0,0);
DMACH1TransferConfig(3,0,0);
// DMACH1WrapConfig(1,0,0,1);
DMACH1ModeConfig(1,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,SYNC_DISABLE,SYNC_SRC,
OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
StartDMACH1();

到此为止

LCD_write_alp(0,0,5);
LCD_write_alp(1,0,17);
LCD_write_alp(2,0,4);
LCD_write_alp(3,0,16);
LCD_write_hanzi(4,0,4);
LCD_write_number(6,0,5);
LCD_write_number(7,0,0);

while(1)
{
GpioDataRegs.GPADAT.bit.GPIO13 = 0;
DELAY_US(100000);
GpioDataRegs.GPADAT.bit.GPIO13 = 1;
DELAY_US(100000);

AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
// while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
// AdcaResult0 = AdcaResultRegs.ADCRESULT0;
// AdcaResult1 = AdcaResultRegs.ADCRESULT1;
Trans_val(AdcaResult0);

}

Terry Deng:

DMA的触发启动条件没有设置啊

请忽略前面部分,直接看后面DMA部分,需要帮忙看的地方会有红字提示:

#include "F28x_Project.h"
#define res1 GPIO_WritePin(58, 1);
#define res0 GPIO_WritePin(58, 0);
#define sce1 GPIO_WritePin(59, 1);
#define sce0 GPIO_WritePin(59, 0);
#define dc1 GPIO_WritePin(72, 1);
#define dc0 GPIO_WritePin(72, 0);
#define sdin1 GPIO_WritePin(73, 1);
#define sdin0 GPIO_WritePin(73, 0);
#define sclk1 GPIO_WritePin(78, 1);
#define sclk0 GPIO_WritePin(78, 0);
Uint16 AdcaResult0;
Uint16 AdcaResult1;
volatile Uint16 *DMADest;
volatile Uint16 *DMASource;

unsigned char number[]={
0xF8,0x04,0x04,0x04,0xF8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x00,0x08,0xFC,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
0x18,0x84,0x44,0x24,0x18,0x00,0x03,0x02,0x02,0x02,0x02,0x00,
0x08,0x04,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x40,0xB0,0x88,0xFC,0x80,0x00,0x00,0x00,0x00,0x03,0x02,0x00,
0x3C,0x24,0x24,0x24,0xC4,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0xF8,0x24,0x24,0x2C,0xC0,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x0C,0x04,0xE4,0x1C,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0xD8,0x24,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x38,0x44,0x44,0x44,0xF8,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
//– . –10
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
//– –11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
unsigned char zimu[]={
/*– a 0–*/
0x00,0x40,0xA0,0xA0,0xC0,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
/*– b 1–*/
0x04,0xFC,0x20,0x20,0xC0,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
/*– c 2–*/
0x00,0xC0,0x20,0x20,0x60,0x00,0x00,0x01,0x02,0x02,0x02,0x00,
//– d 3–
0x00,0xC0,0x20,0x24,0xFC,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
//– e 4–
0x00,0xC0,0xA0,0xA0,0xC0,0x00,0x00,0x01,0x02,0x02,0x02,0x00,
//– f 5–
0x00,0x20,0xF8,0x24,0x24,0x04,0x00,0x02,0x03,0x02,0x02,0x00,
//– g 6–
0x00,0x40,0xA0,0xA0,0x60,0x20,0x00,0x07,0x0A,0x0A,0x0A,0x04,
//– h 7–
0x04,0xFC,0x20,0x20,0xC0,0x00,0x02,0x03,0x02,0x00,0x03,0x02,
//– i 8–
0x00,0x20,0xE4,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
//– j 9–
0x00,0x00,0x20,0xE4,0x00,0x00,0x08,0x08,0x08,0x07,0x00,0x00,
//– k 10–
0x04,0xFC,0x80,0xE0,0x20,0x20,0x02,0x03,0x02,0x00,0x03,0x02,
//– l 11–
0x04,0x04,0xFC,0x00,0x00,0x00,0x02,0x02,0x03,0x02,0x02,0x00,
//– m 12–
0xE0,0x20,0xE0,0x20,0xC0,0x00,0x03,0x00,0x03,0x00,0x03,0x00,
//– n 13–
0x20,0xE0,0x20,0x20,0xC0,0x00,0x02,0x03,0x02,0x00,0x03,0x02,
//– o 14–
0x00,0xC0,0x20,0x20,0xC0,0x00,0x00,0x01,0x02,0x02,0x01,0x00,
//– p 15–
0x20,0xE0,0x20,0x20,0xC0,0x00,0x08,0x0F,0x0A,0x02,0x01,0x00,
//– q 16–
0x00,0xC0,0x20,0x20,0xE0,0x00,0x00,0x01,0x02,0x0A,0x0F,0x08,
//– r 17–
0x20,0xE0,0x40,0x20,0x20,0x00,0x02,0x03,0x02,0x00,0x00,0x00,
//– s 18–
0x00,0x60,0xA0,0xA0,0x20,0x00,0x00,0x02,0x02,0x02,0x03,0x00,
//– t 19–
0x00,0x20,0xF8,0x20,0x00,0x00,0x00,0x00,0x01,0x02,0x02,0x00,
//– u 20–
0x20,0xE0,0x00,0x20,0xE0,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
//– v 21–
0x20,0xE0,0x20,0x80,0x60,0x20,0x00,0x00,0x03,0x01,0x00,0x00,
//– w 22–
0x60,0x80,0xE0,0x80,0x60,0x00,0x00,0x03,0x00,0x03,0x00,0x00,
//– x 23–
0x20,0x60,0x80,0x60,0x20,0x00,0x02,0x03,0x00,0x03,0x02,0x00,
//– y 24–
0x20,0xE0,0x20,0x80,0x60,0x20,0x08,0x08,0x07,0x01,0x00,0x00,
//– z 25–
0x00,0x20,0xA0,0x60,0x20,0x00,0x00,0x02,0x03,0x02,0x02,0x00,
//– . —
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
//– —
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//– _ —
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,
};
unsigned char hanzi[]=
{
0x00,0xFC,0x24,0x24,0x24,0xFF,0x24,0x24,
0x24,0xFE,0x04,0x00,0x00,0x01,0x01,0x01,
0x01,0x07,0x09,0x09,0x09,0x09,0x08,0x0E,//电 12*16
0x08,0x12,0xE4,0x00,0x12,0xD2,0x1A,0xD7,
0x12,0xDA,0x32,0x02,0x01,0x0F,0x00,0x08,
0x04,0x03,0x00,0x0F,0x00,0x07,0x08,0x0F,//流 12*16
0x00,0x00,0xFE,0x02,0x22,0x22,0xFA,0x22,
0xA2,0x32,0x23,0x02,0x0C,0x03,0x08,0x08,
0x08,0x08,0x0F,0x08,0x08,0x09,0x0A,0x08,//压 12*16
0x20,0x10,0xFC,0x03,0x02,0xFA,0xAA,0xAF,
0xAA,0xAA,0xFB,0x02,0x00,0x00,0x0F,0x00,
0x08,0x0F,0x0A,0x0A,0x0A,0x0A,0x0F,0x08,//值 12*16
0x00,0x00,0x8C,0x8C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //: 12*16
0x00,0x20,0xA4,0xA8,0xA0,0xBF,0xA0,0xB0,
0xA8,0xA6,0xF0,0x20,0x00,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0x04,0x0F,0x00,//当 12*16
0x04,0xF4,0x54,0x55,0x56,0xF4,0x04,0xF6,
0x05,0x04,0xF6,0x04,0x00,0x0F,0x01,0x01,
0x09,0x0F,0x00,0x03,0x04,0x08,0x07,0x00,//前 12*16
0x34,0x2C,0xF7,0xA4,0x10,0xE8,0xA4,0xEB,
0x0A,0xC4,0x08,0xE8,0x02,0x01,0x0F,0x00,
0x00,0x0F,0x02,0x0F,0x00,0x03,0x08,0x0F,//输 12*16
0x00,0x80,0x3E,0x10,0x10,0xFF,0x10,0x10,
0x10,0x3E,0x80,0x00,0x00,0x0F,0x04,0x04,
0x04,0x07,0x04,0x04,0x04,0x04,0x0F,0x00,//出 12*16
0x00,0x00,0x00,0x00,0x80,0x63,0x1C,0x60,
0x80,0x00,0x00,0x00,0x04,0x04,0x02,0x01,
0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x04,//入 12*16
0x10,0x11,0xF6,0x00,0x10,0x6F,0xA1,0x21,
0xA1,0x6F,0x10,0x10,0x00,0x00,0x07,0x0A,
0x09,0x04,0x05,0x02,0x05,0x04,0x08,0x08,//设 12*16
0x10,0x0C,0xD4,0x14,0x14,0xF5,0x96,0x94,
0xD4,0x94,0x04,0x0C,0x08,0x04,0x03,0x02,
0x04,0x07,0x08,0x08,0x08,0x08,0x08,0x08,//定 12*16
0x89,0xD2,0x20,0xFE,0x02,0xFA,0x02,0xFF,
0x02,0xFC,0x00,0xFF,0x00,0x0F,0x08,0x04,
0x02,0x01,0x02,0x04,0x00,0x05,0x08,0x07,//测 12*16
0x48,0x24,0xF2,0x09,0x40,0x5F,0x55,0x55,
0x55,0xD5,0x5F,0x40,0x00,0x00,0x0F,0x01,
0x01,0x01,0x07,0x01,0x09,0x0F,0x01,0x01,//得 12*16
};

void LCD_write_byte(unsigned char dt, unsigned char command)
{
unsigned char i;
sce0;
DELAY_US(5);
if(command==1)
{dc1;}
else {dc0;}
DELAY_US(5);
for(i=0;i<8;i++)
{
if(dt&0x80)
{sdin1;}
else
{sdin0;}
dt=dt<<1;
DELAY_US(5);
sclk0;
DELAY_US(5);
sclk1;
}
DELAY_US(5);
dc1;
DELAY_US(5);
sce1;
DELAY_US(5);
sdin1;
DELAY_US(5);
}
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40 | Y, 0);// column
LCD_write_byte(0x80 | X, 0);// row
}
void LCD_clear(void)
{
unsigned char t;
unsigned char k;
LCD_set_XY(0,0);
for(t=0;t<6;t++)
{
for(k=0;k<84;k++)
{
LCD_write_byte(0x00,1);
}
}
}
void LCD_Init()
{
GPIO_SetupPinMux(58, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(58, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(59, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(59, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(72, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(72, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(73, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(73, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(78, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(78, GPIO_OUTPUT, GPIO_PUSHPULL);
res0;
DELAY_US(1000);
res1;
LCD_write_byte(0x21,0);
LCD_write_byte(0xC4,0);//display contrast
LCD_write_byte(0x20,0);
LCD_write_byte(0x0C,0);
LCD_clear();
}
/*———————————————
8*16 number and alphabet
———————————————–*/
void LCD_write_alp(unsigned char row, unsigned char page,unsigned char c)
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<6;i++)
{
LCD_write_byte(zimu[c*12+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=6; i<12;i++)
{
LCD_write_byte(zimu[c*12+i],1);
}
}
void LCD_write_number(unsigned char row, unsigned char page,unsigned char c) //row:? page:? dd:??
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<6;i++)
{
LCD_write_byte(number[c*12+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=6; i<12;i++)
{
LCD_write_byte(number[c*12+i],1);
}
}
/*———————————————
12*16 hanzi
———————————————–*/
void LCD_write_hanzi(unsigned char row, unsigned char page,unsigned char c)
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<12;i++)
{
LCD_write_byte(hanzi[c*24+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=12; i<24;i++)
{
LCD_write_byte(hanzi[c*24+i],1);
}
}
void ConfigureADC(void)
{
EALLOW;

//write configurations
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

//Set pulse positions to late
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;

//power up the ADCs
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;

//delay for 1ms to allow ADC time to power up
DELAY_US(1000);

EDIS;
}
void SetupADCSoftware(void)
{
Uint16 acqps;

//determine minimum acquisition window (in SYSCLKS) based on resolution
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION){
acqps = 14; //75ns
}
else { //resolution is 16-bit
acqps = 63; //320ns
}

//Select the channels to convert and end of conversion flag
//ADCA
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin A1
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
}
void Trans_val(unsigned Hex_Val)
{
unsigned int Curr_Volt;
unsigned char ptr[4];

Curr_Volt = Hex_Val * 0.732422;

ptr[3]=Curr_Volt/1000;//x.000
ptr[2]=Curr_Volt%1000/100;//0.x00
ptr[1]=Curr_Volt%100/10;//0.0×0
ptr[0]=Curr_Volt%10;//0.00x

LCD_write_number(10,1,ptr[3]);
LCD_write_number(11,1,ptr[2]);
LCD_write_number(12,1,ptr[1]);
LCD_write_number(13,1,ptr[0]);
}

main()
{
InitSysCtrl();
InitGpio();
LCD_Init();

GPIO_SetupPinOptions(13, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(13, GPIO_MUX_CPU1, 0);

DINT;
IER = 0x0000;
IFR = 0x0000;

//Configure the ADCs and power them up
ConfigureADC();
//Setup the ADCs for software conversions
SetupADCSoftware();

以下是DMA的配置:

DMAInitialize();
DMADest = &AdcaResult0; //Point DMA destination to the beginning of the array
DMASource = &AdcaResultRegs.ADCRESULT0; //Point DMA source to ADC result register base
DMACH1AddrConfig(DMADest,DMASource);
DMACH1BurstConfig(1,0,0);
DMACH1TransferConfig(3,0,0);
// DMACH1WrapConfig(1,0,0,1);
DMACH1ModeConfig(1,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,SYNC_DISABLE,SYNC_SRC,
OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
StartDMACH1();

到此为止

LCD_write_alp(0,0,5);
LCD_write_alp(1,0,17);
LCD_write_alp(2,0,4);
LCD_write_alp(3,0,16);
LCD_write_hanzi(4,0,4);
LCD_write_number(6,0,5);
LCD_write_number(7,0,0);

while(1)
{
GpioDataRegs.GPADAT.bit.GPIO13 = 0;
DELAY_US(100000);
GpioDataRegs.GPADAT.bit.GPIO13 = 1;
DELAY_US(100000);

AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
// while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
// AdcaResult0 = AdcaResultRegs.ADCRESULT0;
// AdcaResult1 = AdcaResultRegs.ADCRESULT1;
Trans_val(AdcaResult0);

}

Chenghao Wang:

我也遇到这样的问题,不知道你的解决了吗,貌似是DMA没有自动清除ADCA_INT1的中断标志,不知道咋办了

请忽略前面部分,直接看后面DMA部分,需要帮忙看的地方会有红字提示:

#include "F28x_Project.h"
#define res1 GPIO_WritePin(58, 1);
#define res0 GPIO_WritePin(58, 0);
#define sce1 GPIO_WritePin(59, 1);
#define sce0 GPIO_WritePin(59, 0);
#define dc1 GPIO_WritePin(72, 1);
#define dc0 GPIO_WritePin(72, 0);
#define sdin1 GPIO_WritePin(73, 1);
#define sdin0 GPIO_WritePin(73, 0);
#define sclk1 GPIO_WritePin(78, 1);
#define sclk0 GPIO_WritePin(78, 0);
Uint16 AdcaResult0;
Uint16 AdcaResult1;
volatile Uint16 *DMADest;
volatile Uint16 *DMASource;

unsigned char number[]={
0xF8,0x04,0x04,0x04,0xF8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x00,0x08,0xFC,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
0x18,0x84,0x44,0x24,0x18,0x00,0x03,0x02,0x02,0x02,0x02,0x00,
0x08,0x04,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x40,0xB0,0x88,0xFC,0x80,0x00,0x00,0x00,0x00,0x03,0x02,0x00,
0x3C,0x24,0x24,0x24,0xC4,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0xF8,0x24,0x24,0x2C,0xC0,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x0C,0x04,0xE4,0x1C,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0xD8,0x24,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x38,0x44,0x44,0x44,0xF8,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
//– . –10
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
//– –11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
unsigned char zimu[]={
/*– a 0–*/
0x00,0x40,0xA0,0xA0,0xC0,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
/*– b 1–*/
0x04,0xFC,0x20,0x20,0xC0,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
/*– c 2–*/
0x00,0xC0,0x20,0x20,0x60,0x00,0x00,0x01,0x02,0x02,0x02,0x00,
//– d 3–
0x00,0xC0,0x20,0x24,0xFC,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
//– e 4–
0x00,0xC0,0xA0,0xA0,0xC0,0x00,0x00,0x01,0x02,0x02,0x02,0x00,
//– f 5–
0x00,0x20,0xF8,0x24,0x24,0x04,0x00,0x02,0x03,0x02,0x02,0x00,
//– g 6–
0x00,0x40,0xA0,0xA0,0x60,0x20,0x00,0x07,0x0A,0x0A,0x0A,0x04,
//– h 7–
0x04,0xFC,0x20,0x20,0xC0,0x00,0x02,0x03,0x02,0x00,0x03,0x02,
//– i 8–
0x00,0x20,0xE4,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
//– j 9–
0x00,0x00,0x20,0xE4,0x00,0x00,0x08,0x08,0x08,0x07,0x00,0x00,
//– k 10–
0x04,0xFC,0x80,0xE0,0x20,0x20,0x02,0x03,0x02,0x00,0x03,0x02,
//– l 11–
0x04,0x04,0xFC,0x00,0x00,0x00,0x02,0x02,0x03,0x02,0x02,0x00,
//– m 12–
0xE0,0x20,0xE0,0x20,0xC0,0x00,0x03,0x00,0x03,0x00,0x03,0x00,
//– n 13–
0x20,0xE0,0x20,0x20,0xC0,0x00,0x02,0x03,0x02,0x00,0x03,0x02,
//– o 14–
0x00,0xC0,0x20,0x20,0xC0,0x00,0x00,0x01,0x02,0x02,0x01,0x00,
//– p 15–
0x20,0xE0,0x20,0x20,0xC0,0x00,0x08,0x0F,0x0A,0x02,0x01,0x00,
//– q 16–
0x00,0xC0,0x20,0x20,0xE0,0x00,0x00,0x01,0x02,0x0A,0x0F,0x08,
//– r 17–
0x20,0xE0,0x40,0x20,0x20,0x00,0x02,0x03,0x02,0x00,0x00,0x00,
//– s 18–
0x00,0x60,0xA0,0xA0,0x20,0x00,0x00,0x02,0x02,0x02,0x03,0x00,
//– t 19–
0x00,0x20,0xF8,0x20,0x00,0x00,0x00,0x00,0x01,0x02,0x02,0x00,
//– u 20–
0x20,0xE0,0x00,0x20,0xE0,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
//– v 21–
0x20,0xE0,0x20,0x80,0x60,0x20,0x00,0x00,0x03,0x01,0x00,0x00,
//– w 22–
0x60,0x80,0xE0,0x80,0x60,0x00,0x00,0x03,0x00,0x03,0x00,0x00,
//– x 23–
0x20,0x60,0x80,0x60,0x20,0x00,0x02,0x03,0x00,0x03,0x02,0x00,
//– y 24–
0x20,0xE0,0x20,0x80,0x60,0x20,0x08,0x08,0x07,0x01,0x00,0x00,
//– z 25–
0x00,0x20,0xA0,0x60,0x20,0x00,0x00,0x02,0x03,0x02,0x02,0x00,
//– . —
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
//– —
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//– _ —
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,
};
unsigned char hanzi[]=
{
0x00,0xFC,0x24,0x24,0x24,0xFF,0x24,0x24,
0x24,0xFE,0x04,0x00,0x00,0x01,0x01,0x01,
0x01,0x07,0x09,0x09,0x09,0x09,0x08,0x0E,//电 12*16
0x08,0x12,0xE4,0x00,0x12,0xD2,0x1A,0xD7,
0x12,0xDA,0x32,0x02,0x01,0x0F,0x00,0x08,
0x04,0x03,0x00,0x0F,0x00,0x07,0x08,0x0F,//流 12*16
0x00,0x00,0xFE,0x02,0x22,0x22,0xFA,0x22,
0xA2,0x32,0x23,0x02,0x0C,0x03,0x08,0x08,
0x08,0x08,0x0F,0x08,0x08,0x09,0x0A,0x08,//压 12*16
0x20,0x10,0xFC,0x03,0x02,0xFA,0xAA,0xAF,
0xAA,0xAA,0xFB,0x02,0x00,0x00,0x0F,0x00,
0x08,0x0F,0x0A,0x0A,0x0A,0x0A,0x0F,0x08,//值 12*16
0x00,0x00,0x8C,0x8C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //: 12*16
0x00,0x20,0xA4,0xA8,0xA0,0xBF,0xA0,0xB0,
0xA8,0xA6,0xF0,0x20,0x00,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0x04,0x0F,0x00,//当 12*16
0x04,0xF4,0x54,0x55,0x56,0xF4,0x04,0xF6,
0x05,0x04,0xF6,0x04,0x00,0x0F,0x01,0x01,
0x09,0x0F,0x00,0x03,0x04,0x08,0x07,0x00,//前 12*16
0x34,0x2C,0xF7,0xA4,0x10,0xE8,0xA4,0xEB,
0x0A,0xC4,0x08,0xE8,0x02,0x01,0x0F,0x00,
0x00,0x0F,0x02,0x0F,0x00,0x03,0x08,0x0F,//输 12*16
0x00,0x80,0x3E,0x10,0x10,0xFF,0x10,0x10,
0x10,0x3E,0x80,0x00,0x00,0x0F,0x04,0x04,
0x04,0x07,0x04,0x04,0x04,0x04,0x0F,0x00,//出 12*16
0x00,0x00,0x00,0x00,0x80,0x63,0x1C,0x60,
0x80,0x00,0x00,0x00,0x04,0x04,0x02,0x01,
0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x04,//入 12*16
0x10,0x11,0xF6,0x00,0x10,0x6F,0xA1,0x21,
0xA1,0x6F,0x10,0x10,0x00,0x00,0x07,0x0A,
0x09,0x04,0x05,0x02,0x05,0x04,0x08,0x08,//设 12*16
0x10,0x0C,0xD4,0x14,0x14,0xF5,0x96,0x94,
0xD4,0x94,0x04,0x0C,0x08,0x04,0x03,0x02,
0x04,0x07,0x08,0x08,0x08,0x08,0x08,0x08,//定 12*16
0x89,0xD2,0x20,0xFE,0x02,0xFA,0x02,0xFF,
0x02,0xFC,0x00,0xFF,0x00,0x0F,0x08,0x04,
0x02,0x01,0x02,0x04,0x00,0x05,0x08,0x07,//测 12*16
0x48,0x24,0xF2,0x09,0x40,0x5F,0x55,0x55,
0x55,0xD5,0x5F,0x40,0x00,0x00,0x0F,0x01,
0x01,0x01,0x07,0x01,0x09,0x0F,0x01,0x01,//得 12*16
};

void LCD_write_byte(unsigned char dt, unsigned char command)
{
unsigned char i;
sce0;
DELAY_US(5);
if(command==1)
{dc1;}
else {dc0;}
DELAY_US(5);
for(i=0;i<8;i++)
{
if(dt&0x80)
{sdin1;}
else
{sdin0;}
dt=dt<<1;
DELAY_US(5);
sclk0;
DELAY_US(5);
sclk1;
}
DELAY_US(5);
dc1;
DELAY_US(5);
sce1;
DELAY_US(5);
sdin1;
DELAY_US(5);
}
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40 | Y, 0);// column
LCD_write_byte(0x80 | X, 0);// row
}
void LCD_clear(void)
{
unsigned char t;
unsigned char k;
LCD_set_XY(0,0);
for(t=0;t<6;t++)
{
for(k=0;k<84;k++)
{
LCD_write_byte(0x00,1);
}
}
}
void LCD_Init()
{
GPIO_SetupPinMux(58, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(58, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(59, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(59, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(72, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(72, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(73, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(73, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(78, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(78, GPIO_OUTPUT, GPIO_PUSHPULL);
res0;
DELAY_US(1000);
res1;
LCD_write_byte(0x21,0);
LCD_write_byte(0xC4,0);//display contrast
LCD_write_byte(0x20,0);
LCD_write_byte(0x0C,0);
LCD_clear();
}
/*———————————————
8*16 number and alphabet
———————————————–*/
void LCD_write_alp(unsigned char row, unsigned char page,unsigned char c)
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<6;i++)
{
LCD_write_byte(zimu[c*12+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=6; i<12;i++)
{
LCD_write_byte(zimu[c*12+i],1);
}
}
void LCD_write_number(unsigned char row, unsigned char page,unsigned char c) //row:? page:? dd:??
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<6;i++)
{
LCD_write_byte(number[c*12+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=6; i<12;i++)
{
LCD_write_byte(number[c*12+i],1);
}
}
/*———————————————
12*16 hanzi
———————————————–*/
void LCD_write_hanzi(unsigned char row, unsigned char page,unsigned char c)
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<12;i++)
{
LCD_write_byte(hanzi[c*24+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=12; i<24;i++)
{
LCD_write_byte(hanzi[c*24+i],1);
}
}
void ConfigureADC(void)
{
EALLOW;

//write configurations
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

//Set pulse positions to late
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;

//power up the ADCs
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;

//delay for 1ms to allow ADC time to power up
DELAY_US(1000);

EDIS;
}
void SetupADCSoftware(void)
{
Uint16 acqps;

//determine minimum acquisition window (in SYSCLKS) based on resolution
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION){
acqps = 14; //75ns
}
else { //resolution is 16-bit
acqps = 63; //320ns
}

//Select the channels to convert and end of conversion flag
//ADCA
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin A1
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
}
void Trans_val(unsigned Hex_Val)
{
unsigned int Curr_Volt;
unsigned char ptr[4];

Curr_Volt = Hex_Val * 0.732422;

ptr[3]=Curr_Volt/1000;//x.000
ptr[2]=Curr_Volt%1000/100;//0.x00
ptr[1]=Curr_Volt%100/10;//0.0×0
ptr[0]=Curr_Volt%10;//0.00x

LCD_write_number(10,1,ptr[3]);
LCD_write_number(11,1,ptr[2]);
LCD_write_number(12,1,ptr[1]);
LCD_write_number(13,1,ptr[0]);
}

main()
{
InitSysCtrl();
InitGpio();
LCD_Init();

GPIO_SetupPinOptions(13, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(13, GPIO_MUX_CPU1, 0);

DINT;
IER = 0x0000;
IFR = 0x0000;

//Configure the ADCs and power them up
ConfigureADC();
//Setup the ADCs for software conversions
SetupADCSoftware();

以下是DMA的配置:

DMAInitialize();
DMADest = &AdcaResult0; //Point DMA destination to the beginning of the array
DMASource = &AdcaResultRegs.ADCRESULT0; //Point DMA source to ADC result register base
DMACH1AddrConfig(DMADest,DMASource);
DMACH1BurstConfig(1,0,0);
DMACH1TransferConfig(3,0,0);
// DMACH1WrapConfig(1,0,0,1);
DMACH1ModeConfig(1,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,SYNC_DISABLE,SYNC_SRC,
OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
StartDMACH1();

到此为止

LCD_write_alp(0,0,5);
LCD_write_alp(1,0,17);
LCD_write_alp(2,0,4);
LCD_write_alp(3,0,16);
LCD_write_hanzi(4,0,4);
LCD_write_number(6,0,5);
LCD_write_number(7,0,0);

while(1)
{
GpioDataRegs.GPADAT.bit.GPIO13 = 0;
DELAY_US(100000);
GpioDataRegs.GPADAT.bit.GPIO13 = 1;
DELAY_US(100000);

AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
// while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
// AdcaResult0 = AdcaResultRegs.ADCRESULT0;
// AdcaResult1 = AdcaResultRegs.ADCRESULT1;
Trans_val(AdcaResult0);

}

Chenghao Wang:

回复 Terry Deng:

DMACH1ModeConfig函数的第一个参数不就是触发条件,1代表ADCA.1吗

请忽略前面部分,直接看后面DMA部分,需要帮忙看的地方会有红字提示:

#include "F28x_Project.h"
#define res1 GPIO_WritePin(58, 1);
#define res0 GPIO_WritePin(58, 0);
#define sce1 GPIO_WritePin(59, 1);
#define sce0 GPIO_WritePin(59, 0);
#define dc1 GPIO_WritePin(72, 1);
#define dc0 GPIO_WritePin(72, 0);
#define sdin1 GPIO_WritePin(73, 1);
#define sdin0 GPIO_WritePin(73, 0);
#define sclk1 GPIO_WritePin(78, 1);
#define sclk0 GPIO_WritePin(78, 0);
Uint16 AdcaResult0;
Uint16 AdcaResult1;
volatile Uint16 *DMADest;
volatile Uint16 *DMASource;

unsigned char number[]={
0xF8,0x04,0x04,0x04,0xF8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x00,0x08,0xFC,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
0x18,0x84,0x44,0x24,0x18,0x00,0x03,0x02,0x02,0x02,0x02,0x00,
0x08,0x04,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x40,0xB0,0x88,0xFC,0x80,0x00,0x00,0x00,0x00,0x03,0x02,0x00,
0x3C,0x24,0x24,0x24,0xC4,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0xF8,0x24,0x24,0x2C,0xC0,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x0C,0x04,0xE4,0x1C,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0xD8,0x24,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
0x38,0x44,0x44,0x44,0xF8,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
//– . –10
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
//– –11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
unsigned char zimu[]={
/*– a 0–*/
0x00,0x40,0xA0,0xA0,0xC0,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
/*– b 1–*/
0x04,0xFC,0x20,0x20,0xC0,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
/*– c 2–*/
0x00,0xC0,0x20,0x20,0x60,0x00,0x00,0x01,0x02,0x02,0x02,0x00,
//– d 3–
0x00,0xC0,0x20,0x24,0xFC,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
//– e 4–
0x00,0xC0,0xA0,0xA0,0xC0,0x00,0x00,0x01,0x02,0x02,0x02,0x00,
//– f 5–
0x00,0x20,0xF8,0x24,0x24,0x04,0x00,0x02,0x03,0x02,0x02,0x00,
//– g 6–
0x00,0x40,0xA0,0xA0,0x60,0x20,0x00,0x07,0x0A,0x0A,0x0A,0x04,
//– h 7–
0x04,0xFC,0x20,0x20,0xC0,0x00,0x02,0x03,0x02,0x00,0x03,0x02,
//– i 8–
0x00,0x20,0xE4,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
//– j 9–
0x00,0x00,0x20,0xE4,0x00,0x00,0x08,0x08,0x08,0x07,0x00,0x00,
//– k 10–
0x04,0xFC,0x80,0xE0,0x20,0x20,0x02,0x03,0x02,0x00,0x03,0x02,
//– l 11–
0x04,0x04,0xFC,0x00,0x00,0x00,0x02,0x02,0x03,0x02,0x02,0x00,
//– m 12–
0xE0,0x20,0xE0,0x20,0xC0,0x00,0x03,0x00,0x03,0x00,0x03,0x00,
//– n 13–
0x20,0xE0,0x20,0x20,0xC0,0x00,0x02,0x03,0x02,0x00,0x03,0x02,
//– o 14–
0x00,0xC0,0x20,0x20,0xC0,0x00,0x00,0x01,0x02,0x02,0x01,0x00,
//– p 15–
0x20,0xE0,0x20,0x20,0xC0,0x00,0x08,0x0F,0x0A,0x02,0x01,0x00,
//– q 16–
0x00,0xC0,0x20,0x20,0xE0,0x00,0x00,0x01,0x02,0x0A,0x0F,0x08,
//– r 17–
0x20,0xE0,0x40,0x20,0x20,0x00,0x02,0x03,0x02,0x00,0x00,0x00,
//– s 18–
0x00,0x60,0xA0,0xA0,0x20,0x00,0x00,0x02,0x02,0x02,0x03,0x00,
//– t 19–
0x00,0x20,0xF8,0x20,0x00,0x00,0x00,0x00,0x01,0x02,0x02,0x00,
//– u 20–
0x20,0xE0,0x00,0x20,0xE0,0x00,0x00,0x01,0x02,0x02,0x03,0x02,
//– v 21–
0x20,0xE0,0x20,0x80,0x60,0x20,0x00,0x00,0x03,0x01,0x00,0x00,
//– w 22–
0x60,0x80,0xE0,0x80,0x60,0x00,0x00,0x03,0x00,0x03,0x00,0x00,
//– x 23–
0x20,0x60,0x80,0x60,0x20,0x00,0x02,0x03,0x00,0x03,0x02,0x00,
//– y 24–
0x20,0xE0,0x20,0x80,0x60,0x20,0x08,0x08,0x07,0x01,0x00,0x00,
//– z 25–
0x00,0x20,0xA0,0x60,0x20,0x00,0x00,0x02,0x03,0x02,0x02,0x00,
//– . —
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
//– —
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//– _ —
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,
};
unsigned char hanzi[]=
{
0x00,0xFC,0x24,0x24,0x24,0xFF,0x24,0x24,
0x24,0xFE,0x04,0x00,0x00,0x01,0x01,0x01,
0x01,0x07,0x09,0x09,0x09,0x09,0x08,0x0E,//电 12*16
0x08,0x12,0xE4,0x00,0x12,0xD2,0x1A,0xD7,
0x12,0xDA,0x32,0x02,0x01,0x0F,0x00,0x08,
0x04,0x03,0x00,0x0F,0x00,0x07,0x08,0x0F,//流 12*16
0x00,0x00,0xFE,0x02,0x22,0x22,0xFA,0x22,
0xA2,0x32,0x23,0x02,0x0C,0x03,0x08,0x08,
0x08,0x08,0x0F,0x08,0x08,0x09,0x0A,0x08,//压 12*16
0x20,0x10,0xFC,0x03,0x02,0xFA,0xAA,0xAF,
0xAA,0xAA,0xFB,0x02,0x00,0x00,0x0F,0x00,
0x08,0x0F,0x0A,0x0A,0x0A,0x0A,0x0F,0x08,//值 12*16
0x00,0x00,0x8C,0x8C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //: 12*16
0x00,0x20,0xA4,0xA8,0xA0,0xBF,0xA0,0xB0,
0xA8,0xA6,0xF0,0x20,0x00,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0x04,0x0F,0x00,//当 12*16
0x04,0xF4,0x54,0x55,0x56,0xF4,0x04,0xF6,
0x05,0x04,0xF6,0x04,0x00,0x0F,0x01,0x01,
0x09,0x0F,0x00,0x03,0x04,0x08,0x07,0x00,//前 12*16
0x34,0x2C,0xF7,0xA4,0x10,0xE8,0xA4,0xEB,
0x0A,0xC4,0x08,0xE8,0x02,0x01,0x0F,0x00,
0x00,0x0F,0x02,0x0F,0x00,0x03,0x08,0x0F,//输 12*16
0x00,0x80,0x3E,0x10,0x10,0xFF,0x10,0x10,
0x10,0x3E,0x80,0x00,0x00,0x0F,0x04,0x04,
0x04,0x07,0x04,0x04,0x04,0x04,0x0F,0x00,//出 12*16
0x00,0x00,0x00,0x00,0x80,0x63,0x1C,0x60,
0x80,0x00,0x00,0x00,0x04,0x04,0x02,0x01,
0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x04,//入 12*16
0x10,0x11,0xF6,0x00,0x10,0x6F,0xA1,0x21,
0xA1,0x6F,0x10,0x10,0x00,0x00,0x07,0x0A,
0x09,0x04,0x05,0x02,0x05,0x04,0x08,0x08,//设 12*16
0x10,0x0C,0xD4,0x14,0x14,0xF5,0x96,0x94,
0xD4,0x94,0x04,0x0C,0x08,0x04,0x03,0x02,
0x04,0x07,0x08,0x08,0x08,0x08,0x08,0x08,//定 12*16
0x89,0xD2,0x20,0xFE,0x02,0xFA,0x02,0xFF,
0x02,0xFC,0x00,0xFF,0x00,0x0F,0x08,0x04,
0x02,0x01,0x02,0x04,0x00,0x05,0x08,0x07,//测 12*16
0x48,0x24,0xF2,0x09,0x40,0x5F,0x55,0x55,
0x55,0xD5,0x5F,0x40,0x00,0x00,0x0F,0x01,
0x01,0x01,0x07,0x01,0x09,0x0F,0x01,0x01,//得 12*16
};

void LCD_write_byte(unsigned char dt, unsigned char command)
{
unsigned char i;
sce0;
DELAY_US(5);
if(command==1)
{dc1;}
else {dc0;}
DELAY_US(5);
for(i=0;i<8;i++)
{
if(dt&0x80)
{sdin1;}
else
{sdin0;}
dt=dt<<1;
DELAY_US(5);
sclk0;
DELAY_US(5);
sclk1;
}
DELAY_US(5);
dc1;
DELAY_US(5);
sce1;
DELAY_US(5);
sdin1;
DELAY_US(5);
}
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40 | Y, 0);// column
LCD_write_byte(0x80 | X, 0);// row
}
void LCD_clear(void)
{
unsigned char t;
unsigned char k;
LCD_set_XY(0,0);
for(t=0;t<6;t++)
{
for(k=0;k<84;k++)
{
LCD_write_byte(0x00,1);
}
}
}
void LCD_Init()
{
GPIO_SetupPinMux(58, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(58, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(59, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(59, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(72, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(72, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(73, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(73, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(78, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(78, GPIO_OUTPUT, GPIO_PUSHPULL);
res0;
DELAY_US(1000);
res1;
LCD_write_byte(0x21,0);
LCD_write_byte(0xC4,0);//display contrast
LCD_write_byte(0x20,0);
LCD_write_byte(0x0C,0);
LCD_clear();
}
/*———————————————
8*16 number and alphabet
———————————————–*/
void LCD_write_alp(unsigned char row, unsigned char page,unsigned char c)
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<6;i++)
{
LCD_write_byte(zimu[c*12+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=6; i<12;i++)
{
LCD_write_byte(zimu[c*12+i],1);
}
}
void LCD_write_number(unsigned char row, unsigned char page,unsigned char c) //row:? page:? dd:??
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<6;i++)
{
LCD_write_byte(number[c*12+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=6; i<12;i++)
{
LCD_write_byte(number[c*12+i],1);
}
}
/*———————————————
12*16 hanzi
———————————————–*/
void LCD_write_hanzi(unsigned char row, unsigned char page,unsigned char c)
{
unsigned char i;

LCD_set_XY(row*6, page);
for(i=0; i<12;i++)
{
LCD_write_byte(hanzi[c*24+i],1);
}

LCD_set_XY(row*6, page+1);
for(i=12; i<24;i++)
{
LCD_write_byte(hanzi[c*24+i],1);
}
}
void ConfigureADC(void)
{
EALLOW;

//write configurations
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

//Set pulse positions to late
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;

//power up the ADCs
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;

//delay for 1ms to allow ADC time to power up
DELAY_US(1000);

EDIS;
}
void SetupADCSoftware(void)
{
Uint16 acqps;

//determine minimum acquisition window (in SYSCLKS) based on resolution
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION){
acqps = 14; //75ns
}
else { //resolution is 16-bit
acqps = 63; //320ns
}

//Select the channels to convert and end of conversion flag
//ADCA
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin A1
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
}
void Trans_val(unsigned Hex_Val)
{
unsigned int Curr_Volt;
unsigned char ptr[4];

Curr_Volt = Hex_Val * 0.732422;

ptr[3]=Curr_Volt/1000;//x.000
ptr[2]=Curr_Volt%1000/100;//0.x00
ptr[1]=Curr_Volt%100/10;//0.0×0
ptr[0]=Curr_Volt%10;//0.00x

LCD_write_number(10,1,ptr[3]);
LCD_write_number(11,1,ptr[2]);
LCD_write_number(12,1,ptr[1]);
LCD_write_number(13,1,ptr[0]);
}

main()
{
InitSysCtrl();
InitGpio();
LCD_Init();

GPIO_SetupPinOptions(13, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(13, GPIO_MUX_CPU1, 0);

DINT;
IER = 0x0000;
IFR = 0x0000;

//Configure the ADCs and power them up
ConfigureADC();
//Setup the ADCs for software conversions
SetupADCSoftware();

以下是DMA的配置:

DMAInitialize();
DMADest = &AdcaResult0; //Point DMA destination to the beginning of the array
DMASource = &AdcaResultRegs.ADCRESULT0; //Point DMA source to ADC result register base
DMACH1AddrConfig(DMADest,DMASource);
DMACH1BurstConfig(1,0,0);
DMACH1TransferConfig(3,0,0);
// DMACH1WrapConfig(1,0,0,1);
DMACH1ModeConfig(1,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,SYNC_DISABLE,SYNC_SRC,
OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
StartDMACH1();

到此为止

LCD_write_alp(0,0,5);
LCD_write_alp(1,0,17);
LCD_write_alp(2,0,4);
LCD_write_alp(3,0,16);
LCD_write_hanzi(4,0,4);
LCD_write_number(6,0,5);
LCD_write_number(7,0,0);

while(1)
{
GpioDataRegs.GPADAT.bit.GPIO13 = 0;
DELAY_US(100000);
GpioDataRegs.GPADAT.bit.GPIO13 = 1;
DELAY_US(100000);

AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
// while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
// AdcaResult0 = AdcaResultRegs.ADCRESULT0;
// AdcaResult1 = AdcaResultRegs.ADCRESULT1;
Trans_val(AdcaResult0);

}

user4432499:

回复 Chenghao Wang:

感觉TI给的源文件有问题啊,对应于第一个自变量的语句是DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH1,是SysCtrl里面的寄存器,而不是对应于通道触发条件的DmaRegs.CH1.MODE.bit.PERINTSEL

赞(0)
未经允许不得转载:TI中文支持网 » 求助28377S 使用DMA的ADC程序 目标地址始终没有收到ADC数据
分享到: 更多 (0)