1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7)
#define LCD_ENABLE_PIN PIN_B0
#define LCD_RS_PIN PIN_B1
#define LCD_RW_PIN PIN_B2
#define LCD_TYPE 2
#include <lcd.c>
#define SYNCH_BUTTON PIN_d0
float const quantum=5.0/255.0;
int signal;
void initialize(void)
{
setup_adc(ADC_CLOCK_INTERNAL);//enables the a/d module //and sets the clock to internal adc clock
setup_adc(ADC_CLOCK_DIV_32);
setup_adc_ports(ALL_ANALOG);//sets all the adc pins to analog
set_adc_channel(0); //the next read_adc call will read channel 0
delay_us(10); //a small delay is required after setting the channel //and before read
set_tris_c (0x00);
initialize();
SET_TRIS_A(0xff);
lcd_init();
delay_ms(6);
printf(lcd_putc,"wirless ECG", );
delay_ms(5000);
while(1)
{
signal=read_adc();//ADC_READ_ONLY);//reads the result of the last conversion
delay_ms(50);
output_c(signal*quantum);
if((input(SYNCH_BUTTON)==1))
{
printf(lcd_putc,"synchronisation", );
printf("signal = %2.2F\n\r", signal*quantum);
}
}
} |
Partager