Jump to content

simplelogic

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About simplelogic

  • Rank
    Newbrie
  1. after writing in Hi-Tech C, will i be able to compile this in sourceboost, if I can not how do I go about changing this solve problem of programming a microcontroller using 16F84 or what do you recommend for a pic 16F87X or perhaps 16F818/819? //# define # include < pic . h> #define rs RA2 #define e RA1 #define lcd_data PORTB #define _XTAL_FREQ 4000000 void delayms(unsigned int itime); void pulse(void); void send_char(unsigned char data); void lcd_goto(unsigned char data); void lcd_clr(void); void send_string(const char *s); void init_lcd(void); void dis_num(unsigned int data,unsigned char digit); void prog1(void); unsigned long no=0; void main (void) { TRISA=0; TRISB=0; TRISA3=1; init_lcd(); delayms(10); lcd_clr(); delayms(10); send_string("Heart rate meter"); delayms(1000); lcd_clr(); delayms(10); while(1) { prog1(); } } void prog1(void) { unsigned int temp1=0,temp2=0; unsigned char i; unsigned int hb=1; while(RA3); while(!RA3){ hb++; delayms(1); } hb=30000/hb; lcd_goto(2); send_string("H.B.R: bpm"); lcd_goto(8); dis_num(hb,3); } void delayms(unsigned int itime) { unsigned int i; for(;itime>0;itime--) { __delay_ms(1); } } void send_config(unsigned char data) //send lcd configuration { rs=0; //set lcd to configuration mode lcd_data=data&0xf0; //lcd data port = data pulse(); lcd_data=(data<<4)&0xf0; pulse(); } void pulse(void) { e=1; //pulse e to confirm the data delayms(1); e=0; delayms(1); } void lcd_goto(unsigned char data) //set the location of the lcd cursor { //if the given value is (0-15) the send_config(0x80+data); //cursor will be at the lower line } void lcd_clr(void) //clear the lcd { send_config(0x01); delayms(2); } void send_string(const char *s) //send a string to display in the lcd { rs = 1; while (*s)send_char (*s++); } void send_char(unsigned char data) //send lcd character { rs =1; delayms(1); //set lcd to display mode lcd_data=data&0xf0; //lcd data port = data pulse(); lcd_data=(data<<4)&0xf0; pulse(); } void init_lcd(void) { rs=0;e=0; //command mode delayms(10); //delay 10ms lcd_data=0x30; //load initial nibble pulse(); //Latch initial code delayms(5); //delay 5ms pulse(); //Latch initial code delayms(1); //delay 1ms pulse(); //Latch initial code lcd_data=0x20; pulse(); //Latch initial code //configure lcd send_config(0x28); //Set 4-bit mode, 2 lines send_config(0xF); //Switch off display send_config(0x06); //Enable cursor auto increase } void dis_num(unsigned int data,unsigned char digit) { if(digit>3) send_char('0'+(data/1000)%10); if(digit>2) send_char('0'+(data/100)%10); if(digit>1) send_char('0'+(data/10)%10); if(digit>0) send_char('0'+(data/1)%10); } I intend to simulate heart beat pulse initially before actually programming the pic and using it in my circuit to record heart rate on lcd screen, can any one help or am I in the wrong forum because I am new here.
×
×
  • Create New...