📄 da5615.c
字号:
/*------------------------------------------------------------------------------
TEST.C: ISD51 Demo for TI MSC 1210
Copyright 2003 Keil Software, Inc.
------------------------------------------------------------------------------*/
#include <REG1210.H>
#include <intrins.h>
#include <stdio.h>
#include "ISD51.h"
#include "ROM.H"
#define XTAL 11059200 // XTAL frequency 11.0592 MHz
// defines for UART BAUDRATE
#define BAUDRATE 9600 // 9600bps communication baudrate
#define T2RELOAD (65536-(XTAL/32/BAUDRATE))
sbit Load = P1^1; //5615 control bit
sbit YellowLed = P2^4;// EVM Ledlight
void delay(void) {
long i;
i =0x0ff07;
while(i--);
}
void Send_SpiData3(unsigned char h,unsigned char l)
{
Load =0;
SPIDATA = h;
while((AIE&0x08) != 0x08){};
SPIDATA = l;
while((AIE&0x08) != 0x08){};
Load = 1;
//printf("\nSPI Send high Value %X ** low Value %X",h,l);
}
void main (void) {
// Setup Serial Interface 0
T2CON = 0x34; // Use Timer 2 as baudrate generator
RCAP2H = 0xFF;
RCAP2H = (T2RELOAD >> 8); // baudrate reload factor
RCAP2L = T2RELOAD;
SCON0 = 0x50; // enable serial uart & receiver
PCON |= 0x80; // double baudrate for UART0
P3DDRL &= 0xF0; // P3DDRL set port pins of UART0 to input/strong drive output
P3DDRL |= 0x07; // P3DDRL set port pins of UART0 to input/strong drive output
// System Timer Setup
// The following settings are important for ISD51 (enable flash programming, disable watchdog)
USEC = ((XTAL+500000)/1000000)-1; // USEC timer factor
ONEMS = (XTAL/1000)-1; // (MSECH+MSCL) MS Timer counting at 1.0ms
HMSEC = 100-1; // Hundred MS Timer to 100.0ms
SECINT = (10-1) | 0x80; // SECINT= 10 * HMS Timer Rate = 1 sec
// '0x80' will set the MSB for write immediate
MSINT = (10-1) | 0x80; // MSINT = 10ms for Tone period time base
PDCON = 0x3D; // Powerup SysTimer
FTCON = 0xA5; // setup flash programming times
EICON = 0x40; //DIS enable all auxiliary interrupts
#if 1 // init ISD51 and wait until the uVision2 Debugger connects
ISDwait (); // wait for connection to uVision2 Debugger
#endif
//Set SPI Registers
P1 = 0xFF;
AIE = 0x00;
PDCON &=0xFE;
P1DDRH = 0x75;
SPITCON = 0x18; //VERY IMPORTANT
SPICON = 0x04;
EA = 1; //DIS Enable global interrupt flag
while (1) {
Send_SpiData3(0x0F,0x00) ;
delay();
delay();
delay();
Send_SpiData3(0x00,0x00) ;
delay();
delay();
delay();
YellowLed = !YellowLed;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -