sana_akhtar
Member level 2
- Joined
- Apr 21, 2012
- Messages
- 47
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,606
#include <htc.h>
#include <stdlib.h>
//#include <stdio.h>
#include "lcd.h"
#include "uart.h"
#ifndef _XTAL_FREQ
// Unless specified elsewhere, 4MHz system frequency is assumed
#define _XTAL_FREQ 4000000
#endif
#define sensor RA4
#define len1 10
int count=0;
void interrupt isr(void) // Here be interrupt function - the name is
{
count+=1; // Add 1 to count - insert idle comment
T0IF = 0; // Clear interrupt flag, ready for next
GIE=1;
T0IE=1;
}
void main(void)
{
unsigned char jj[len1];
TRISA=1;
PORTA=0;
UART_Init(9600);
lcd_init();
lcd_goto(0);
lcd_puts("No. of Sh:");
lcd_goto(11);
T0IE=1;
GIE=1;
PEIE=1;
T0CS=1; // if T0CS=0, it works. But I want to work with external interrupt.
T0SE=0;
PSA=0;
PS0=0;
PS1=0;
PS2=0;
while(1)
{
lcd_goto(11);
itoa(jj,count,10);
lcd_puts(jj);
UART_Write_Text(jj);
}
}
#include <htc.h>
#include <stdlib.h>
#include <stdio.h>
#include "lcd.h"
#include "uart.h"
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000
#endif
#define sensor RA4
#define len1 10
int count=0;
int timer_count=0;
void main(void)
{
unsigned char count_str[len1];
unsigned char time_str[len1];
TRISA=1;
PORTA=0;
UART_Init(9600);
lcd_init();
lcd_goto(0);
lcd_puts("Sheets:");
lcd_goto(0x40);
lcd_puts("sh/h:");
// counter
TMR0=0;
TMR0=0;
T0CS=1;
T0SE=0;
//timer
TMR1CS=0;
T1OSCEN=0;
T1CKPS1=1;
T1CKPS0=1;
TMR1L=0;
TMR1ON=1;
while(1)
{
timer_count= TMR1L; //timer
count=count +TMR0; // counter
TMR0=0;
lcd_goto(8);
itoa(count_str,count,10);
lcd_puts(count_str);
lcd_goto(0x48);
itoa(time_str,timer_count,10);
lcd_puts(time_str);
}
}
if(TMR0 != old_count)
{
old_count = TMR0;
timer_count = TMR1L;
TMR1L = 0;
<the remainder of the LCD routines>
}
#include <htc.h>
#include <stdlib.h>
#include <stdio.h>
#include "lcd.h"
#include "uart.h"
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000
#endif
#define sensor RA4
#define len1 10
int new_count=0;
int old_count=0;
float timer_count=0;
void main(void)
{
unsigned char count_str[len1];
unsigned char time_str[len1];
// TRISA=1;
// PORTA=0;
UART_Init(9600);
lcd_init();
lcd_goto(0);
lcd_puts("Sheets:");
lcd_goto(0x40);
lcd_puts("sh/h:");
// counter
TMR0=0;
T0CS=1;
T0SE=0;
//timer
TMR1CS=0;
T1OSCEN=0;
T1CKPS1=1;
T1CKPS0=1;
TMR1L=0;
TMR1ON=1;
while(1)
{
new_count=old_count + TMR0; // counter
TMR0=0;
lcd_goto(8);
itoa(count_str,new_count,10);
lcd_puts(count_str); //print counter on LCD
if (old_count!= new_count)
{
TMR1ON=0;
timer_count=3600/((TMR1H,TMR1L)*0.00000025); // timer .. calculate time b/w two counts
// no. of sensor response per hour.
TMR1ON=1;
lcd_goto(0x46);
my_float_func(time_str,timer_count); //display time on LCD
TMR1L=0;
TMR1H=0;
}
old_count=new_count;
}
}
new_count=old_count + TMR0; // counter
timer_count=3600/((TMR1H,TMR1L)*0.00000025); // timer .. calculate time b/w two counts
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?