Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help in CCS program

Status
Not open for further replies.

beckhamho

Junior Member level 1
Joined
Apr 15, 2010
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,411
Hi

I am connected a missing pulse detector to pin2(RA0) of a PIC16f877a.
Basically the missing pulse detector will always given high output, and change to low output if sense missing pulse.It will change back to high after a short period. I need to write a program when the output change to low, the LCD will display number = 1. And the number will increase by one every time the output change to low. Below is the program i wrote, but it doesn't work.

Code:
#include <16f877a.h>
#use delay(clock=20000000)
#fuses hs,noprotect,nowdt,nolvp
#define use_portb_lcd TRUE
#include <lcd.c>
#define PWR_LED Pin_A5
#define IR1 Pin_A0

void main()
{ 
   int interrupt = 0;
  SETUP_ADC_PORTS(NO_ANALOGS);
  setup_adc(adc_off);
    lcd_init();

     {
   if (input(IR1) == True)  /this code is used for check H or L using a LED
     output_high(PWR_LED);
     else
     output_low(PWR_LED);
     
      lcd_putc("\fAutomatic Room");
      lcd_putc("\nLight Controller");
      delay_ms(5000);
      lcd_putc("\f");
     
     
      lcd_gotoxy(1,1);
      lcd_putc("People in = \n");
     
      if(input(IR1)==0)   / if the input is low
      {
         interrupt+=1;         increment by one
         lcd_gotoxy(13,1);   display on first row,13th column
         lcd_putc(interrupt);
      }
   }while(1);
}

Code:
if (input(IR1) == True) /this code is used for check High or Low using a LED
output_high(PWR_LED);
else
output_low(PWR_LED);

the problem i facing is the above code couldn't work if combine with the LCD code. It could work if the code compile separately. below show the independent code that worked fine.
Code:
#include <16F877a.h>
#use delay(clock=20000000)
#fuses HS, NOWDT, NOPROTECT, NOPUT, NOLVP


#define PWR_LED Pin_A5
#define IR1 Pin_A0

void main()
{


   While(1)
   {
     if (input(IR1) == True)
     output_high(PWR_LED);
    else
     output_low(PWR_LED);
   }
     
}

the next problem is below code didn't show any response in the LCD. i am trying to write the code that when the input is low, lcd on 1st row,13th digit will increase by one everytime the input change to low. Please figure out the problem for me.
Code:
if(input(IR1)==0) / if the input is low
{
interrupt+=1; increment by one
lcd_gotoxy(13,1); display on first row,13th column
lcd_putc(interrupt);
}
}while(1);

Thanks for the help, really appreciate
 

can you be more specific about the kind of errors you see? If they are compilation errors or some unexpected results?
 

I think your problem is the

while(1); ????

The code will get here and then do nothing else.

I think you are missing a do.

do{
blah blah
}while(1);
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top