📄 usb.c
字号:
//#include <ADuC842.h>
#include <stdio.h>
#include <rs_usb.h>
sbit TEM = P2^0;
sbit ADXL_Y = P1^4;
signed long int i=0;
signed int s_data=-1;
unsigned char c=0;
unsigned int data_adc=0x3000;
unsigned char volume=1;
unsigned int DAC_Data=0;
void delay(unsigned long int length) { while(length--) s_data = ReadByte(); }
void adc_int() interrupt 6 {
DAC0 = ((ADCDATA&0x0FFF)-volume);
// DAC0 = ~DAC0;
/* SendByte(SEC);
SendByte(MIN);
if (ADCDATA>(data_adc+100)) data_adc = data_adc+100; else
if (ADCDATA<(data_adc-100)) data_adc = data_adc-100; else
if (ADCDATA>data_adc) data_adc++; else
if (ADCDATA<data_adc) data_adc--;
SendByte(data_adc>>8);
SendByte(data_adc&0xFF);
SendByte(i<<24);
SendByte((i<<16)&0xFF);
SendByte((i<<8)&0xFF);
SendByte(i&0xFF);
SendByte(P0);
SendByte(P1);
SendByte(P2);
SendByte(P3);
delay(0x00FF);
LED = !LED;*/
return;
}
void main (void)
{
TxD_USB = 1; // Wysoki stan na linii nadawczej
DSR_USB = 0; // Niski stan na linii gotowo渃i odbioru
PLLCON = 0x01; //PLL Clock config
P1 = 0x7F; // Port P1.7 jako Digital Input;
DelayUs(0x01);
ADCCON1 = 0x8C;
ADCCON2 = 0x0B;
ADCCON3 = 0x25;
ADCCON2 = 0x0C;
ADCCON3 = 0x27;
ADCCON1 = B10100000;// power up ADC /8 + 4 acq clock
ADCCON2 = B00100011;// select channel to convert
DACCON = B01111111;
// EA = 1; // enable interrupts
// EADC = 1; // enable ADC interrupt
// CCONV = 1; // begin continuous conversions
while (1) {
while(!ADCI);
// DAC_Data = ADCDATA&0x0FFF;
DAC0 = (ADCDATA&0x0FFF)/volume;
// if (DAC_Data>0) DAC0 = (DAC_Data>>volume)+0x0800;
// if (DAC_Data<0) DAC0 = (-((-DAC_Data)>>volume))+0x0800;
if (!INT0) volume=3;
if (!INT1) volume=2;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -