elmariacci
Üye
- Katılım
- 17 Şub 2012
- Mesajlar
- 14
- Puanları
- 1
- Yaş
- 34
ccs c'de nabiz ölçer yapmaya çalişiyorum pice programi yüklüyorum ama olmuyor Lcd de nabiz ölçer yazmasi lazim ama hiç bişey yok.proteus da simule ederken hiç sorun yok.
program şu şekilde arkadaşalar bi bakin yanliş yer var mi programi derlediğimde hata bulmuyor sadece bi kaç tane uyari veriyor
#include "sw2.h"
#zero_ram
unsigned long int display[10];
unsigned long int a,heart_rate;
unsigned int sira;
#define LCD_EN PIN_B2
#define LCD_RS PIN_B1
#define LCD_D0 PIN_D3
#define LCD_D1 PIN_B3
#define LCD_D2 PIN_D2
#define LCD_D3 PIN_B4
#define ROLE PIN_B5
#include "lcd_mini.h"
#int_EXT
void EXT_isr(void)
{
unsigned long int b,c;
b=a;
c=a;
c=50000/c;
if((c<200) && (c>40)){
display[0]=display[1];
display[1]=display[2];
display[2]=display[3];
display[3]=display[4];
display[4]=display[5];
display[5]=display[6];
display[6]=display[7];
display[7]=display[8];
display[8]=display[9];
display[9]=40000/b;
heart_rate=(display[0]+display[1]+display[2]+display[3]+display[4]+display[5]+display[6]+display[7]+display[8]+display[9])/10;
printf(lcd_putc,"\1NABIZ=%3Lu A=%3Lu \2NABIZ OLCER",heart_rate,display[9]);
if(heart_rate>=120) output_high(ROLE); else output_low(ROLE);
}
a=0;
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_4,200,12);
setup_ccp1(CCP_OFF);
delay_ms(1000);
// input(PIN_A4);
lcd_init();
printf(lcd_putc,"\1NABIZ \2OLCER");
delay_ms(1000);
printf(lcd_putc,"\f");
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(1){
delay_ms(1);
a++;
// if(a>=3000){
// a=3000;
// output_high(ROLE);
// }
// else
// output_low(ROLE);
}
}
bu da lcd programi
void lcd_delay(int data){
int i;
for(i=0; i<data; ++i);
}
void LCD_PulseEnable (){
output_high ( LCD_EN );
delay_ms(2);
output_low ( LCD_EN );
delay_ms(2);
}
void LCD_SetData (int cX ){
output_bit ( LCD_D0, cX & 0x01 );
output_bit ( LCD_D1, cX & 0x02 );
output_bit ( LCD_D2, cX & 0x04 );
output_bit ( LCD_D3, cX & 0x08 );
}
void lcd_adr ( int cX ){
LCD_SetData ( swap ( cX ) | 0x08 );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
}
void LCD_PutCmd ( int cX ){
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
}
void lcd_putc ( int cX ){
switch (cx) {
case '\f' : LCD_PutCmd ( 0x01 ); delay_ms(2); break;
case '\1' : lcd_adr( 0x00 ); delay_ms(2); break;
case '\2' : lcd_adr(0x40); delay_ms(2); break;
default :
output_high ( LCD_RS );
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
output_low ( LCD_RS );
}
}
void lcd_init (){
// output_low ( LCD_rw );
output_low ( LCD_RS );
LCD_SetData ( 0x00 );
delay_ms ( 100 ); // wait enough time after Vdd rise
LCD_SetData ( 0x03 ); // init with specific nibbles to start 4-bit mode
LCD_PulseEnable ();
LCD_PulseEnable ();
LCD_PulseEnable ();
LCD_SetData ( 0x02 ); //* set 4-bit interface
LCD_PulseEnable (); //* send dual nibbles hereafter, MSN first
LCD_PutCmd ( 0x2C ); //* function set (all lines, 5x7 characters)
LCD_PutCmd ( 0x0C ); //* display ON, cursor off, no blink
LCD_PutCmd ( 0x01 ); //* clear display
LCD_PutCmd ( 0x06 ); //* entry mode set, increment & scroll left
}
void lcd_refresh(void){
// output_low ( LCD_rw );
output_low ( LCD_RS );
LCD_SetData ( 0x00 );
delay_ms ( 100 ); // wait enough time after Vdd rise
LCD_SetData ( 0x03 ); // init with specific nibbles to start 4-bit mode
LCD_PulseEnable ();
//LCD_PulseEnable ();
//LCD_PulseEnable ();
LCD_SetData ( 0x02 ); //* set 4-bit interface
LCD_PulseEnable (); //* send dual nibbles hereafter, MSN first
LCD_PutCmd ( 0x2C ); //* function set (all lines, 5x7 characters)
LCD_PutCmd ( 0x0C ); //* display ON, cursor off, no blink
//LCD_PutCmd ( 0x01 ); //* clear display
LCD_PutCmd ( 0x06 ); //* entry mode set, increment & scroll left
}
void lcd_gotoxy(int8 x, int8 y){
if(y==1){
lcd_adr( 0x00+x-1 ); delay_ms(2);
}else{
lcd_adr( 0x40+x-1 ); delay_ms(2);
}
}
program şu şekilde arkadaşalar bi bakin yanliş yer var mi programi derlediğimde hata bulmuyor sadece bi kaç tane uyari veriyor
#include "sw2.h"
#zero_ram
unsigned long int display[10];
unsigned long int a,heart_rate;
unsigned int sira;
#define LCD_EN PIN_B2
#define LCD_RS PIN_B1
#define LCD_D0 PIN_D3
#define LCD_D1 PIN_B3
#define LCD_D2 PIN_D2
#define LCD_D3 PIN_B4
#define ROLE PIN_B5
#include "lcd_mini.h"
#int_EXT
void EXT_isr(void)
{
unsigned long int b,c;
b=a;
c=a;
c=50000/c;
if((c<200) && (c>40)){
display[0]=display[1];
display[1]=display[2];
display[2]=display[3];
display[3]=display[4];
display[4]=display[5];
display[5]=display[6];
display[6]=display[7];
display[7]=display[8];
display[8]=display[9];
display[9]=40000/b;
heart_rate=(display[0]+display[1]+display[2]+display[3]+display[4]+display[5]+display[6]+display[7]+display[8]+display[9])/10;
printf(lcd_putc,"\1NABIZ=%3Lu A=%3Lu \2NABIZ OLCER",heart_rate,display[9]);
if(heart_rate>=120) output_high(ROLE); else output_low(ROLE);
}
a=0;
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_4,200,12);
setup_ccp1(CCP_OFF);
delay_ms(1000);
// input(PIN_A4);
lcd_init();
printf(lcd_putc,"\1NABIZ \2OLCER");
delay_ms(1000);
printf(lcd_putc,"\f");
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(1){
delay_ms(1);
a++;
// if(a>=3000){
// a=3000;
// output_high(ROLE);
// }
// else
// output_low(ROLE);
}
}
bu da lcd programi
void lcd_delay(int data){
int i;
for(i=0; i<data; ++i);
}
void LCD_PulseEnable (){
output_high ( LCD_EN );
delay_ms(2);
output_low ( LCD_EN );
delay_ms(2);
}
void LCD_SetData (int cX ){
output_bit ( LCD_D0, cX & 0x01 );
output_bit ( LCD_D1, cX & 0x02 );
output_bit ( LCD_D2, cX & 0x04 );
output_bit ( LCD_D3, cX & 0x08 );
}
void lcd_adr ( int cX ){
LCD_SetData ( swap ( cX ) | 0x08 );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
}
void LCD_PutCmd ( int cX ){
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
}
void lcd_putc ( int cX ){
switch (cx) {
case '\f' : LCD_PutCmd ( 0x01 ); delay_ms(2); break;
case '\1' : lcd_adr( 0x00 ); delay_ms(2); break;
case '\2' : lcd_adr(0x40); delay_ms(2); break;
default :
output_high ( LCD_RS );
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
output_low ( LCD_RS );
}
}
void lcd_init (){
// output_low ( LCD_rw );
output_low ( LCD_RS );
LCD_SetData ( 0x00 );
delay_ms ( 100 ); // wait enough time after Vdd rise
LCD_SetData ( 0x03 ); // init with specific nibbles to start 4-bit mode
LCD_PulseEnable ();
LCD_PulseEnable ();
LCD_PulseEnable ();
LCD_SetData ( 0x02 ); //* set 4-bit interface
LCD_PulseEnable (); //* send dual nibbles hereafter, MSN first
LCD_PutCmd ( 0x2C ); //* function set (all lines, 5x7 characters)
LCD_PutCmd ( 0x0C ); //* display ON, cursor off, no blink
LCD_PutCmd ( 0x01 ); //* clear display
LCD_PutCmd ( 0x06 ); //* entry mode set, increment & scroll left
}
void lcd_refresh(void){
// output_low ( LCD_rw );
output_low ( LCD_RS );
LCD_SetData ( 0x00 );
delay_ms ( 100 ); // wait enough time after Vdd rise
LCD_SetData ( 0x03 ); // init with specific nibbles to start 4-bit mode
LCD_PulseEnable ();
//LCD_PulseEnable ();
//LCD_PulseEnable ();
LCD_SetData ( 0x02 ); //* set 4-bit interface
LCD_PulseEnable (); //* send dual nibbles hereafter, MSN first
LCD_PutCmd ( 0x2C ); //* function set (all lines, 5x7 characters)
LCD_PutCmd ( 0x0C ); //* display ON, cursor off, no blink
//LCD_PutCmd ( 0x01 ); //* clear display
LCD_PutCmd ( 0x06 ); //* entry mode set, increment & scroll left
}
void lcd_gotoxy(int8 x, int8 y){
if(y==1){
lcd_adr( 0x00+x-1 ); delay_ms(2);
}else{
lcd_adr( 0x40+x-1 ); delay_ms(2);
}
}