ADUC7039 spi通讯,收不到主机的数据
2019-07-15 07:19发布
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
ADUC7039 SPI从机模式,收不到主机数据
1.while((PLLSTA&0x2)==0) {}
// Ensure That thePLL is locked to the 3%
// SysClock=20.48MHz/2=10.24MHz (POWCON:CD=1 by default)
/* timer2 setup ADuC7039 */
T2CON = 0; // Disable watchdog timer
/* Timer0 setup ADuC7039 */
T0CON = 0x002A; // clock = SysClock/16384=625Hz, Count down, Periodic
T0LD = 625; // 625Hz/625 = 1Hz
/* GPIO setup ADuC7039 */
GPCON = 0x00001111; // all GPIO configured as SPI
GPSET = 0x00000000; // GPSET=0 does not affect GPIO output level
GPCLR = 0x00000000; // GPCLR=0 does not affect GPIO output level
GPDAT = 0x34000000; //GPIO_2(MISO)/4/5 set as output, write 1;
SPICON = 0x0109; //0809
/* ADC setup ADuC7036/39 */
ADC0CON = 0x8001; // enable I-ADC, twos complement, gain=2
ADC1CON = 0x8200; // enable V-ADC & T-ADC, select V-ADC,
ADCFLT = 0x0007; // AF=0,SF=7,F_ADC=512KHz/(SF+1)/64=1KHz
ADCMSKI = 0x07; // enable all ADC interrupt
ADCMDE = 0x01; // ADC normal mode, continuous conversion
/* ADC setup ADuC7032 */
// ADC0CON = 0x8001; // enable I-ADC, twos complement, gain=2
// ADC1CON = 0x8200; // enable V-ADC, unipolar coding
// ADC2CON = 0x8200; // enable T-ADC, unipolar coding, internal Temp sensor
// ADCFLT = 0x0007; // AF=0,SF=7,F_ADC=512KHz/(SF+1)/64=1KHz
// ADCMSKI = 0x07; // enable all ADC interrupt
// ADCMDE = 0x01; // ADC normal mode, continuous conversion
/* IRQ/FIR setup */
IRQ = Vector_IRQ;
FIQ = Vector_FIQ;
IRQEN = 0x00000200;// SPI inti 0x4: Enable Timer0 int 0x00000004
FIQEN = 0x00000100; // ADuC7039 only: Enable ADC int
一周热门 更多>