QuestionsCategory: Questionsprepaid energy meter
victor salapion asked 2 years ago

i’ m still stacking on my codes to count two inputs pulses from ADE7755 (ENERGY METER IC) to micro-controller PIC16F877A using MICRO C compiler. 
I NEED YOUR HELP.
 

// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections


unsigned int my_counter = 0;

void interrupt(void){
if (PIR1.TMR1IF){
my_counter++;
PIR1.TMR1IF = 0; //reset timer1 flag
TMR1L = 0xFF;
TMR1H = 0x83;
}
}
void main() {

portb = 0x00;
//trisa = 0xff;
trisb = 0x00;
//ADC_INIT();

T1CON.TMR1CS = 0; // Fosc / 4
T1CON.T1CKPS1 = 1; // Setting prescale value to 1:8
T1CON.T1CKPS0 = 1; // "

T1CON.TMR1ON = 1; //turn on timer1

TMR1L = 0xFF;
TMR1H = 0x83;

PIE1.TMR1IE = 1;
PIR1.TMR1IF = 0;
INTCON.PEIE = 1;
INTCON.GIE = 1;

while(1){
if (my_counter >= 5){
portb = ~portb;
my_counter = 0;
}
}
 
victor salapion replied 2 years ago

please you can correct me on good codes using micro c compiler,
i’m using two ADCs, so i need to count pulses with in 20 seconds per each input pulses to pic16f877A

2 Answers
Dishant Shah Staff answered 2 years ago

Hi
I will get through this and update you as soon as possible.

victor salapion replied 2 years ago

okay Dishant

Dishant Shah Staff answered 2 years ago

Hi,
 
Your required solution is available here.