Jump to content

MPLAB C18 frage


Guest Wolfman

Recommended Posts

Guest Wolfman

also der folgende code funzt nich kann mir jemand sagen ob ich da was falsch mache?

#include <p18f452.h>
#pragma romdata CONFIG
_CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H,
                 _CONFIG2L_DEFAULT,
                   _CONFIG2H_DEFAULT & _WDT_OFF_2H,
                   _CONFIG3H_DEFAULT,
                   _CONFIG4L_DEFAULT & _LVP_OFF_4L,
                   _CONFIG5L_DEFAULT,
                   _CONFIG5H_DEFAULT,
                    _CONFIG6L_DEFAULT,
                 _CONFIG6H_DEFAULT,
                   _CONFIG7L_DEFAULT,
                   _CONFIG7H_DEFAULT);
#pragma romdata

void main(void)
{
      
      TRISBbits.TRISB0 = 1;
      TRISBbits.TRISB1 = 1;
      TRISBbits.TRISB2 = 0;
      INTCON2bits.RBPU = 0;

      while(1) {      

            if(PORTBbits.RB0 == 0) {
                  PORTBbits.RB2 = 1;
            }else if(PORTBbits.RB1 == 0) {
                  PORTBbits.RB2 = 0;
            }
      }
}

Es soll ein led ein und auschalten und auf RB0 und RB1 sind 2 taster das komische ist das ich totall latenz zeit hab wenn ich den taster betätige und wenn ich das led ausschalte mit dem anderen taster schaltet sich das led wieder ein :(

Link to comment
Share on other sites

Guest Wolfman

My Problem in Englisch:

The Source Code Above seems to work but it dont Work i use Pic18f452 and have 2 buttons and one led the first button hangs on RB0 the second on RB1,.

If i press RB0 the led should go on.

If i press RB1 the led should go off.

Here comes the fault wenn i start the led is on and when i press RB1 the led goes off but after a little time it goes on and i dont know why :( is there a fault in my C-Code?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...