飞思卡尔智能车大赛技术报告 下载本文

内容发布更新时间 : 2024/12/23 12:21:19星期一 下面是文章的全部内容请认真阅读。

void SCI0_Init_40M(void) {

/* Init_SCI init code */ SCI0CR1 = 0x00;

SCI0SR2 = 0x80; /* Switch to the alternative register set */ SCI0ASR1 = 0x83; /* Clear alternative status flags */ SCI0ACR1 = 0x00; SCI0ACR2 = 0x00;

SCI0SR2 = 0x00; /* Switch to the normal register set */ (void) SCI0SR1; /* Reset interrupt request flags */ SCI0CR2 = 0x00; /* Disable error interrupts */ SCI0BD = 0x16; /* Set prescaler bits */ //115200

SCI0CR2 |= (SCI0CR2_TE_MASK | SCI0CR2_RE_MASK); /* Enable transmitter, Enable receiver */ }

void SCI0_Init_64M(void){

SCI0BDH=0x01; //When IREN=0, then SCI baud rate=SCI bus clock/(16*SBR[12:0]) SCI0BDL=0xa1; //SCI bus clock=BUs clock=64MHz,so if stet 9600 buad rate,then SBR[12:0]=0x01a1=417

SCI0CR2=0x2c; //enable Receive Full Interrupt,RX enable,Tx enable }

PIT:

void PIT_Init_40M(void) {

PITCFLMT_PITE=0; //PIT定时中断通道0关 PITCE_PCE0 = 1; //Enable Timer Channel0

PITMUX_PMUX0 = 0; //16-bit timer counts with micro time base 0 //time-out period = (PITMTLD + 1) * (PITLD + 1) / fBUS //1ms

31

PITMTLD0 = 199; //PIT Micro Timer Load Register PITLD0 = 199; //PIT Load Register

PITINTE_PINTE0 = 1; //Enable Timer Channel0 Interrupt PITCFLMT_PITE = 1; //Enable Timer }

void PIT_Init_64M(void) {

PITCFLMT_PITE=0; //PIT定时中断通道0关 PITCE_PCE0 = 1; //Enable Timer Channel0

PITMUX_PMUX0 = 0; //16-bit timer counts with micro time base 0 //time-out period = (PITMTLD + 1) * (PITLD + 1) / fBUS //1ms

PITMTLD0 = 319; //PIT Micro Timer Load Register PITLD0 = 199; //PIT Load Register

PITINTE_PINTE0 = 1; //Enable Timer Channel0 Interrupt PITCFLMT_PITE = 1; //Enable Timer }

波形显示 通过Nokia5110显示CCD完成一次赛道信息采集:

void LCD_write_line(unsigned char *ptr) {

unsigned char line; LCD_set_XY(8,5);

LCD_write_byte(0xAA, 1); LCD_set_XY(9,5);

for (line=0; line<64; line++) {

32

if(*(ptr+2*line)==1) LCD_write_byte(0xBD, 1); else

LCD_write_byte(0x81, 1); }

LCD_set_XY(73,5); LCD_write_byte(0xAA, 1); }

33