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
Hey
This code is triggering the timer on RA4 and every timer interrupt add 1 to "count" variable. I want to display this count on LCD But there is some mistake I couldnt figure out because of which it is not displaying on LCDIt is working with internal Clock but not from external transition at the pin. WHYYYY?? Frustrated
This code is triggering the timer on RA4 and every timer interrupt add 1 to "count" variable. I want to display this count on LCD But there is some mistake I couldnt figure out because of which it is not displaying on LCDIt is working with internal Clock but not from external transition at the pin. WHYYYY?? Frustrated
Code:
#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);
}
}
Last edited: