📄 daqevm.bak
字号:
// Texas Instruments
// Name: DaqEvm.c
// Revision: 1.0
// Description: MSC1210 DAQ-EMV Demo
#include "reg1210.h"
#include <stdio.h>
extern char March_C_Plus_Sysram(void);
extern void ROM_Checksum(void);
extern void autobaud(void);
extern void tx_hex(char);
extern void tx_byte(char);
extern char rx_byte_echo(void);
extern char rx_hex_echo(void);
extern void putcr(void);
extern signed long summer(void);
extern signed long bipolar(void);
sbit TP1 = P1^2;
sbit TP2 = P1^3;
sbit TP3 = P1^4;
sbit TP4 = P1^5;
sbit TP5 = P1^6;
sbit TP6 = P1^7;
void portio(void)
{
while(RI==0){
printf("\x1b[5;1HTP123456:%c%c%c%c%c%c",
(char)TP1|0x30,(char)TP2|0x30,(char)TP3|0x30,
(char)TP4|0x30,(char)TP5|0x30,(char)TP6|0x30);
P1= (P1 | 0x04)+8;
}
}
void greeting(void)
{
T2CON = 0x34; // T2 as baudrate generator
RCAP2 = 65535; // 57600 Baud @ 1.8432MHz
SCON = 0x52; // Async mode 1, 8-bit UART, enable rcvr, TI=1, RI=0
printf("\x1b[1;34;46m\x1b[2J\x1b[12CMSC1210 DAQ-EVM\nSelect Function:");
}
void acquire(void)
{ // Measure Ainx to AinCom voltage
signed long int data adres;
char j, ain;
DECIMATION = 144; // Data Rate = ACLK/64/144 = 100.00Hz
ADCON0 = 0x30; // Vref on 2.5V, Buff on, BOD off, PGA 1
printf("\x1b[8;1HAin0\tAin1\tAin2\tAin3\tAin4\tAin5\tAin6\tAin7\n");
while(RI==0){
printf("\x1b[9;1H");
for (ain=8;ain<0x88;ain+=0x10) {
ADMUX=ain;
ADCON1 = 0x01; // bipolar, auto, self calibration, offset, gain
for (j=0;j<5;j++)adres=bipolar(); // discard initial 5 conversions
adres=bipolar();
printf(" \x1b[7D%ld\t",adres);
}
}
RI=0;
}
void MinMax(char key)
{ // Measure Ain0 to Ain0 voltage
signed long int data adres, min, max, n=0;
char j, ain, start=0;
DECIMATION = 1440; // Data Rate = ACLK/64/1440 = 10.00Hz
ADCON0 = 0x30; // Vref on 2.5V, Buff on, BOD off, PGA 1
if (key=='5') ADMUX=0;
if (key=='6') ADMUX=1;
ADCON1 = 0x01; // bipolar, auto, self calibration, offset, gain
for (j=0;j<5;j++)adres=bipolar(); // discard initial 5 conversions
printf("\x1b[11;1HMin\tNew\tMax\tP-P\tN");
while(RI==0){
SSCON = 0; // Clear Summation Registers
SSCON = 0xE4; // acc shift enable, accum 32x, right shift = div 32
adres = summer();
if (start==0){ start=1; min=adres; max=adres; }
else {
if (adres>max) max=adres;
if (adres<min) min=adres;
}
printf("\x1b[12;1H\x1b[K");
printf("%ld\t%ld\t%ld\t%ld\t%ld",min,adres,max,max-min,++n);
}
RI=0;
}
void main(void)
{ char key;
greeting();
PDCON &= 0x0f7; //turn on adc
ACLK = 1; // ACLK = 1.8432MHz/(1+1)= 0.9216MHz
while(1) {
// prompt i/p
printf("\x1b[37m\x1b[3;1H1)Port I/O 2)ROM CheckSum 3)XData 4)ADC 5)MinMax0-0 6)MinMax0-1: \x1b[1D");
key=rx_byte_echo();
if (key=='1') portio();
if (key=='2') { printf("\x1b[6;1HROM CheckSum: \x1b[4D"); ROM_Checksum();}
if (key=='3') {
printf("\x1b[7;1HXdata Test: \x1b[4D");
if (March_C_Plus_Sysram()) printf("Pass");
else printf("Fail");
}
if (key=='4') acquire();
if (key=='5') MinMax(key);
if (key=='6') MinMax(key);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -