1
\$\begingroup\$

I want to write program with " MPLAB IDE v8.50>>Pic18f452 " by 1) low level pulse & 2)Rising edge . but, how?(without interupt & micro C,maybe!) I wrote this program with falling edge. Thanks a lot.

enter image description here enter image description here

This is my circuit in proteus 7.7 .

enter image description here

\$\endgroup\$
4
  • 3
    \$\begingroup\$ MPLAB IDE 8 v8.50 is not a compiler, it is the integrated development environment. Also, the way your circuit is wired, pressing SW1 places the PC into reset by pulling _MCLR low - no code will execute while the button is pressed. \$\endgroup\$ Commented Jul 3, 2015 at 12:13
  • \$\begingroup\$ Argh! I draw a nice schematic showing how to connect up a PIC 18F452 for a pushbutton input and LED output, but uploading images is apparently totally broken right now. There are more things that need to be said than in the one answer you have gotten, but if I can't post my own schematics then this site doesn't work for me. \$\endgroup\$ Commented Jul 3, 2015 at 14:53
  • \$\begingroup\$ There are several issues here. MCLR should be tied to Vcc through a 33k or so resistor (assuming 5v Vcc.) This is because MCLR/VPP is raised to >10v to program the device. Also, the switch will not pull MCLR down as shown (unless R1 is a very low value.) Additionally, the LED needs a current-limiting resistor. (PIC outputs are current-limited to 20mA, so the LED may illuminate fine, but it is a bad idea to rely on another component for this.) \$\endgroup\$
    – rdtsc
    Commented Jul 3, 2015 at 18:29
  • \$\begingroup\$ @OlinLathrop,How can I access to your shematic draw? \$\endgroup\$
    – Phoenix
    Commented Jul 3, 2015 at 19:09

1 Answer 1

1
\$\begingroup\$
  1. You must use below circuit.
  2. Define RB0 as input (TRISB = 1).
  3. Enable RB0 interrupt (INTCON = 0b10010000).
  4. Put your code on interrupt subroutine.

enter image description here

Here's a sample code writing in mikroC for PIC:

void interrupt(void)
{
  if (INTCON.INTF)
  {
    // your code
    INTCON.INTF = 0;
  }
}

void main()
{
  TRISB = 0b00000001;
  INTCON = 0b10010000; 
  while (1) ;
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.