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.

Problem getting input from pin B4 & B5 -pic18f4550

Status
Not open for further replies.

nicko-391

Member level 2
Joined
Dec 8, 2010
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Sri Lanka
Activity points
1,542
Im using pic18f4550.Im checking input state of B4 & b5 in main programme. (Im using ccs)
If input are high another sub programme should run.But programme can not check the input.Whats the wrong?please help.
 

"Whats the wrong?"

Without any program source we cannot help to you!
 

void main(){

glcd_init(on);
enable_interrupts(int_ext);
setup_timer_0(RTCC_INTERNAL | RTCC_div_256);
enable_interrupts(Global);
set_timer0(0);
ext_int_edge(1);

while(1){

read_es(); // this is a sub programme

if(input(pin_b4)){

while(input(pin_b4)){
}


glcd_init(off);
glcd_init(on);
data_mode=1;
init_ext_eeprom();
last_adress=read_ext_eeprom(0x00);
data_logger(); // This is a sub programme
}
}
}


This is the main programme.My problem is whether pin B4 is high data_logger sub programme is not executed.:-(
 

From your code (commented by me):
Code:
 if (input(pin_b4)) {           
     [COLOR="blue"]//runs only if pin_4 is equal to 1[/COLOR]

     while (input(pin_b4)) {    
     } [COLOR="red"]//but this loop is waiting until pin_4 == 0[/COLOR]

  ...
  ... [COLOR="blue"]//so your instructions here are not executed until pin_4 goes to 0[/COLOR]
  ...
 }

My recommendation:
at first write a simple program to sense the input pin state only,
and only then continue if it is already working well.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top