Strange PIC18F1220 behaviour

Discussion in 'Embedded Systems and Microcontrollers' started by ecka333, Feb 23, 2011.

  1. ecka333

    Thread Starter Active Member

    Oct 1, 2009
    76
    0
    I wrote simple code:
    On reset relay must be turned off (RA2 low level). But instead of this after reset relay turns on and there is no reaction when i push button SW1 (RB6 port).
    But when i change PORTB configuration to PORTB=11000000; then everything is working ok: on turn on relay is denergised, on button SW1 press relay coil energises. So how to explain such microcontroller behaviour? How RB6 is connected with RB7? Tried to write the same code in MikroC and HiTech, result is the same.
     
  2. ecka333

    Thread Starter Active Member

    Oct 1, 2009
    76
    0
    Forgot to write configuration words:
    Configuration bits settings:


    IESO=0 Internal External Switchover mode disabled
    FSCM=0 Fail-Safe Clock Monitor disabled
    FOSC<3:0>=0010 HS oscillator
    BORV1:BORV0=00 VBOR set to 4.5V
    BOR=1 Brown-out Reset enabled
    PWRTEN=0 PWRT enabled
    WDTPS<3:0>=0000 Watchdog Timer Postscale 1:1
    WDT=0: WDT disabled
    MCLRE=0 RA5 input pin enabled, MCLR disabled
    DEBUG=1 Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
    LVP=0 Low-Voltage ICSP disabled
    STVR=0 Stack full/underflow will not cause Reset
    CP1=1 Block 1 ((000800-000FFFh) not code-protected
    CP0=1 Block 0 (000200-0007FFh) not code-protected
    CPD=1 Data EEPROM not code-protected
    CPB=1 Boot Block (000000-0001FFh) not code-protected
    WRT1=1 Block 1 (000800-000FFFh) not write-protected
    WRT0=1 Block 0 (000200-0007FFh) not write-protected
    WRTD=1 Data EEPROM not write-protected
    WRTB=1 Boot Block (000000-0001FFh) not write-protected
    WRTC=1 Configuration registers (300000-3000FFh) not write-protected
    EBTR1=1 Block 1 (000800-000FFFh) not protected from table reads executed in other blocks
    EBTR0=1 Block 0 (000200-0007FFh) not protected from table reads executed in other blocks
    EBTRB=1 Boot Block (000000-0001FFh) not protected from table reads executed in other blocks
     
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Code ( (Unknown Language)):
    1.  
    2. [LEFT]binary->0b number or 0B number->0b10011010
    3. octal->0 number->0763
    4. decimal->number->129
    5. hexadecimal->0x number or 0X number->0x2F[/LEFT]
    6.  
    7.  
    Somehow it seams as you have used octal numbers in your coding:rolleyes:
     
Loading...