Define not properly handled!?

Help
Anonymous
2013-01-18
2013-03-12
  • Anonymous - 2013-01-18

    I have an issue with SDCC. My version is 3.2.0 and I use Piklab on Fedora Linux.
    I'm a beginner in c/c++, so help is welcome. My problem is that RB5 is no set high on my PIC16f886 when defined as LCD_RS. It seams to be ignored completely. I can use LCD_HAND = 0b11100000 and it is being set to high on the RB5 output. Also LCD_RW and LCD_EN work just fine.

    As said any help is welcome!

    main.c

    /* ----------------------------------------------------------------------- */
    /* Template source file generated by piklab */
    #include <pic16f886.h>
    #include <delay.h>
    #include <hd44780.h>
    #define __PIC16F886
    /* ----------------------------------------------------------------------- */
    /* Configuration bits: adapt to your setup and needs */
    typedef unsigned int word;
    word __at _CONFIG1 CONFIG1 = _EXTRC_OSC_CLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_ON & _DEBUG_OFF;
    word __at _CONFIG2 CONFIG2 = _BOR40V & _WRT_OFF;
    void isr( void ) __interrupt 0 {                                                                                                                                        
        /* << insert interrupt code >> */
    }
    void main() { 
        init_lcd(); 
        while(1)  {} 
    }
    

    hd44780.h

    #include <pic16f886.h>
    #ifndef HD44780_H
    /* 
     * Start Header Content
     */ 
    // Define HD44780_H
    #define HD44780_H
    #define LCD_DATA    PORTC 
    #define LCD_DATA_ADDR   TRISC 
    #define LCD_HAND    PORTB 
    #define LCD_HAND_ADDR   TRISB 
    #define LCD_RS  RB5
    #define LCD_RW  RB6
    #define LCD_EN  RB7
    #define LCD_D4  RC4
    #define LCD_D5  RC5
    #define LCD_D6  RC6
    #define LCD_D7  RC7
    #define DATA_MASK   0b11110000
    #define HAND_MASK   0b11100000
    #define LCD_SET_DELAY() _delay_us(1)  // 1us -- >40 ns
    #define LCD_BIT_DELAY() _delay_us(5)  // 5us -- >250 ns
    #define LCD_EXE_DELAY() _delay_us(50) // >50 us
    #define LCD_CLR_DELAY() _delay_ms(2) // >1.6 ms
    // function prototypes
    void init_lcd( void ); 
    /* 
     * End Header Content 
     */
    #endif
    

    hd44780.c

    #include <hd44780.h> 
    #include <delay.h> 
    void set_data( void )
    {
      unsigned int mask;
      mask = ~DATA_MASK;
      LCD_DATA_ADDR &= mask;
    }
    void set_handshake( void )
    {
      unsigned int mask; 
      mask = ~HAND_MASK;
      LCD_HAND_ADDR &= mask;
    }
    void init_lcd( void ) 
    { 
      set_data(); 
      set_handshake(); 
      _delay_ms(15); 
      LCD_RS  = 1; 
      LCD_RW = 1; 
      LCD_EN  = 1; 
      LCD_DATA = 0b11110000; 
    }
    
     
  • Raphael Neider

    Raphael Neider - 2013-01-20

    Any progress on this one?

    When I compile hd44780.c (after removing #include <delay.h> and _delay_ms()) with the current sdcc r8389 (sdcc -v), I get an assembler file that contains

    _init_lcd       ;Function start
    ; 2 exit points
    ;       .line   20; "hd44780.c" set_data();
            CALL    _set_data
    ;       .line   21; "hd44780.c" set_handshake();
            CALL    _set_handshake
    ;       .line   25; "hd44780.c" LCD_RS  = 1;
            BANKSEL _PORTBbits
            BSF     _PORTBbits,5
    ;       .line   26; "hd44780.c" LCD_RW = 1;
            BSF     _PORTBbits,6
    ;       .line   27; "hd44780.c" LCD_EN  = 1;
            BSF     _PORTBbits,7
    ;       .line   29; "hd44780.c" LCD_DATA = 0b11110000;
            MOVLW   0xf0
            MOVWF   _PORTC
            RETURN
    ; exit point of _init_lcd
    

    which looks pretty good to me. Can you post the relevant excerpt from your .asm file / output for comparison?

     
  • Anonymous - 2013-01-21

    It did the same, I removed the delay.h but the result is the same. I even tried on another linux distro (Gentoo) but always the same. It seams no to respect the define. Curious because all looks good. Could it be the simulation? I tested with gpsim and Proteus. Both do the same, not setting the RB5 pin to high.

    Here is my generated hd44780.asm

    ;--------------------------------------------------------
    ; File Created by SDCC : free open source ANSI-C Compiler
    ; Version 3.2.0 #8008 (Jan 11 2013) (Linux)
    ; This file was generated Mon Jan 21 09:53:15 2013
    ;--------------------------------------------------------
    ; PIC port for the 14-bit core
    ;--------------------------------------------------------
        .file   "hd44780.c"
        list    p=16f886
        radix dec
        include "p16f886.inc"
    ;--------------------------------------------------------
    ; external declarations
    ;--------------------------------------------------------
        extern  __delay_us
        extern  __delay_ms
        extern  _ADCON0bits
        extern  _ADCON1bits
        extern  _ANSELbits
        extern  _ANSELHbits
        extern  _BAUDCTLbits
        extern  _CCP1CONbits
        extern  _CCP2CONbits
        extern  _CM1CON0bits
        extern  _CM2CON0bits
        extern  _CM2CON1bits
        extern  _ECCPASbits
        extern  _EECON1bits
        extern  _INTCONbits
        extern  _IOCBbits
        extern  _OPTION_REGbits
        extern  _OSCCONbits
        extern  _OSCTUNEbits
        extern  _PCONbits
        extern  _PIE1bits
        extern  _PIE2bits
        extern  _PIR1bits
        extern  _PIR2bits
        extern  _PORTAbits
        extern  _PORTBbits
        extern  _PORTCbits
        extern  _PORTEbits
        extern  _PSTRCONbits
        extern  _PWM1CONbits
        extern  _RCSTAbits
        extern  _SPBRGbits
        extern  _SPBRGHbits
        extern  _SRCONbits
        extern  _SSPCONbits
        extern  _SSPCON2bits
        extern  _SSPSTATbits
        extern  _STATUSbits
        extern  _T1CONbits
        extern  _T2CONbits
        extern  _TRISAbits
        extern  _TRISBbits
        extern  _TRISCbits
        extern  _TRISEbits
        extern  _TXSTAbits
        extern  _VRCONbits
        extern  _WDTCONbits
        extern  _WPUBbits
        extern  _INDF
        extern  _TMR0
        extern  _PCL
        extern  _STATUS
        extern  _FSR
        extern  _PORTA
        extern  _PORTB
        extern  _PORTC
        extern  _PORTE
        extern  _PCLATH
        extern  _INTCON
        extern  _PIR1
        extern  _PIR2
        extern  _TMR1L
        extern  _TMR1H
        extern  _T1CON
        extern  _TMR2
        extern  _T2CON
        extern  _SSPBUF
        extern  _SSPCON
        extern  _CCPR1L
        extern  _CCPR1H
        extern  _CCP1CON
        extern  _RCSTA
        extern  _TXREG
        extern  _RCREG
        extern  _CCPR2L
        extern  _CCPR2H
        extern  _CCP2CON
        extern  _ADRESH
        extern  _ADCON0
        extern  _OPTION_REG
        extern  _TRISA
        extern  _TRISB
        extern  _TRISC
        extern  _TRISE
        extern  _PIE1
        extern  _PIE2
        extern  _PCON
        extern  _OSCCON
        extern  _OSCTUNE
        extern  _SSPCON2
        extern  _PR2
        extern  _SSPADD
        extern  _SSPMSK
        extern  _MSK
        extern  _SSPSTAT
        extern  _WPUB
        extern  _IOCB
        extern  _VRCON
        extern  _TXSTA
        extern  _SPBRG
        extern  _SPBRGH
        extern  _PWM1CON
        extern  _ECCPAS
        extern  _PSTRCON
        extern  _ADRESL
        extern  _ADCON1
        extern  _WDTCON
        extern  _CM1CON0
        extern  _CM2CON0
        extern  _CM2CON1
        extern  _EEDATA
        extern  _EEDAT
        extern  _EEADR
        extern  _EEDATH
        extern  _EEADRH
        extern  _SRCON
        extern  _BAUDCTL
        extern  _ANSEL
        extern  _ANSELH
        extern  _EECON1
        extern  _EECON2
        extern PSAVE
        extern SSAVE
        extern WSAVE
        extern STK12
        extern STK11
        extern STK10
        extern STK09
        extern STK08
        extern STK07
        extern STK06
        extern STK05
        extern STK04
        extern STK03
        extern STK02
        extern STK01
        extern STK00
    ;--------------------------------------------------------
    ; global declarations
    ;--------------------------------------------------------
        global  _init_lcd
        global  _set_data
        global  _set_handshake
    ;--------------------------------------------------------
    ; global definitions
    ;--------------------------------------------------------
    ;--------------------------------------------------------
    ; absolute symbol definitions
    ;--------------------------------------------------------
    ;--------------------------------------------------------
    ; compiler-defined variables
    ;--------------------------------------------------------
    UDL_hd44780_0   udata
    r0x1000 res 1
    ;--------------------------------------------------------
    ; initialized data
    ;--------------------------------------------------------
    ;--------------------------------------------------------
    ; overlayable items in internal ram 
    ;--------------------------------------------------------
    ;   udata_ovr
    ;--------------------------------------------------------
    ; code
    ;--------------------------------------------------------
    code_hd44780    code
    ;***
    ;  pBlock Stats: dbName = C
    ;***
    ;entry:  _init_lcd  ;Function start
    ; 2 exit points
    ;has an exit
    ;functions called:
    ;   _set_data
    ;   _set_handshake
    ;   __delay_ms
    ;   _set_data
    ;   _set_handshake
    ;   __delay_ms
    ;1 compiler assigned register :
    ;   STK00
    ;; Starting pCode block
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2757:genLabel *{*
    ;; ***  genLabel  2760
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2339:genFunction *{*
    ;; ***  genFunction  2341 curr label offset=8previous max_key=0 
    _init_lcd   ;Function start
    ; 2 exit points
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2085:genCall *{*
    ;; ***  genCall  2087
    ;;; gen.c:1800:saveRegisters *{*
    ;; ***  saveRegisters  1802
    ;; >>> gen.c:2174:genCall
        .line   20; "hd44780.c" set_data(); 
        CALL    _set_data
    ;;; gen.c:1844:unsaveRegisters *{*
    ;; ***  unsaveRegisters  1846
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2085:genCall *{*
    ;; ***  genCall  2087
    ;;; gen.c:1800:saveRegisters *{*
    ;; ***  saveRegisters  1802
    ;; >>> gen.c:2174:genCall
        .line   21; "hd44780.c" set_handshake(); 
        CALL    _set_handshake
    ;;; gen.c:1844:unsaveRegisters *{*
    ;; ***  unsaveRegisters  1846
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2085:genCall *{*
    ;; ***  genCall  2087
    ;;; gen.c:1800:saveRegisters *{*
    ;; ***  saveRegisters  1802
    ;;  2134 left AOP_LIT
    ;;; gen.c:1342:mov2w_op *{*
    ;; >>> gen.c:1360:mov2w_op
        .line   23; "hd44780.c" _delay_ms(15); 
        MOVLW   0x0f
    ;;  2134 left AOP_LIT
    ;; >>> gen.c:2142:genCall
    ;; ***  popRegFromIdx,1042  , rIdx=0x7f
        MOVWF   STK00
    ;;; gen.c:1342:mov2w_op *{*
    ;; >>> gen.c:1360:mov2w_op
        MOVLW   0x00
    ;; >>> gen.c:2172:genCall
        PAGESEL __delay_ms
    ;; >>> gen.c:2174:genCall
        CALL    __delay_ms
    ;; >>> gen.c:2180:genCall
        PAGESEL $
    ;;; gen.c:1844:unsaveRegisters *{*
    ;; ***  unsaveRegisters  1846
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:6667:genPointerSet *{*
    ;; ***  genPointerSet  6668
    ;;; gen.c:6486:genNearPointerSet *{*
    ;; ***  genNearPointerSet  6487
    ;;  613
    ;;  aopForRemat 392
    ;;  418: rname _PORTBbits, val 0, const = 0
    ;; ***  genNearPointerSet  6502
    ;;  833: aopGet AOP_PCODE type PO_IMMEDIATE
    ;;  _PORTBbits
    ;;  line = 6504 result AOP_PCODE=_PORTBbits, size=2, left -=-, size=0, right AOP_LIT=0x01, size=1
    ;;; gen.c:6212:genPackBits *{*
    ;; ***  genPackBits  6213
    ;;  833: aopGet AOP_PCODE type PO_IMMEDIATE
    ;;  _PORTBbits
    ;; >>> gen.c:6238:genPackBits
        .line   25; "hd44780.c" LCD_RS = 1; 
        BANKSEL _PORTBbits
        BSF _PORTBbits,5
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:6667:genPointerSet *{*
    ;; ***  genPointerSet  6668
    ;;; gen.c:6486:genNearPointerSet *{*
    ;; ***  genNearPointerSet  6487
    ;;  613
    ;;  aopForRemat 392
    ;;  418: rname _PORTBbits, val 0, const = 0
    ;; ***  genNearPointerSet  6502
    ;;  833: aopGet AOP_PCODE type PO_IMMEDIATE
    ;;  _PORTBbits
    ;;  line = 6504 result AOP_PCODE=_PORTBbits, size=2, left -=-, size=0, right AOP_LIT=0x01, size=1
    ;;; gen.c:6212:genPackBits *{*
    ;; ***  genPackBits  6213
    ;;  833: aopGet AOP_PCODE type PO_IMMEDIATE
    ;;  _PORTBbits
    ;; >>> gen.c:6238:genPackBits
        .line   26; "hd44780.c" LCD_RW = 1; 
        BSF _PORTBbits,6
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:6667:genPointerSet *{*
    ;; ***  genPointerSet  6668
    ;;; gen.c:6486:genNearPointerSet *{*
    ;; ***  genNearPointerSet  6487
    ;;  613
    ;;  aopForRemat 392
    ;;  418: rname _PORTBbits, val 0, const = 0
    ;; ***  genNearPointerSet  6502
    ;;  833: aopGet AOP_PCODE type PO_IMMEDIATE
    ;;  _PORTBbits
    ;;  line = 6504 result AOP_PCODE=_PORTBbits, size=2, left -=-, size=0, right AOP_LIT=0x01, size=1
    ;;; gen.c:6212:genPackBits *{*
    ;; ***  genPackBits  6213
    ;;  833: aopGet AOP_PCODE type PO_IMMEDIATE
    ;;  _PORTBbits
    ;; >>> gen.c:6238:genPackBits
        .line   27; "hd44780.c" LCD_EN = 1; 
        BSF _PORTBbits,7
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:6908:genAssign *{*
    ;; ***  genAssign  6909
    ;; ***  aopForSym 315
    ;;  327 sym->rname = _PORTC, size = 1
    ;;  line = 6918 result AOP_DIR=_PORTC, size=1, left -=-, size=0, right AOP_LIT=0xf0, size=1
    ;; ***  genAssign  7004
    ;; >>> gen.c:7011:genAssign
        .line   29; "hd44780.c" LCD_DATA = 0b11110000; 
        MOVLW   0xf0
    ;; >>> gen.c:7013:genAssign
    ;;  1009
    ;;  1028  _PORTC   offset=0
        MOVWF   _PORTC
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2757:genLabel *{*
    ;; ***  genLabel  2760
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2522:genEndFunction *{*
    ;; ***  genEndFunction  2524
        RETURN  
    ; exit point of _init_lcd
    ;***
    ;  pBlock Stats: dbName = C
    ;***
    ;entry:  _set_handshake ;Function start
    ; 2 exit points
    ;has an exit
    ;2 compiler assigned registers:
    ;   r0x1000
    ;   r0x1001
    ;; Starting pCode block
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2757:genLabel *{*
    ;; ***  genLabel  2760
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2339:genFunction *{*
    ;; ***  genFunction  2341 curr label offset=4previous max_key=0 
    _set_handshake  ;Function start
    ; 2 exit points
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:7101:genCast *{*
    ;; ***  genCast  7102
    ;; ***  aopForSym 315
    ;;  327 sym->rname = _TRISB, size = 1
    ;;  694 register type nRegs=2
    ;;  line = 7110 result AOP_REG=r0x104A, size=2, left -=-, size=0, right AOP_DIR=_TRISB, size=1
    ;; >>> gen.c:7279:genCast
    ;;  1009
    ;;  1028  _TRISB   offset=0
        .line   15; "hd44780.c" LCD_HAND_ADDR &= mask;
        BANKSEL _TRISB
        MOVF    _TRISB,W
    ;; >>> gen.c:7280:genCast
    ;;  1108 rIdx = r0x104A 
        BANKSEL r0x1000
        MOVWF   r0x1000
    ;; ***  addSign  826
    ;;; genarith.c:827:addSign *{*
    ;; >>> genarith.c:846:addSign
    ;;  1108 rIdx = r0x104B 
    ;;1 CLRF    r0x1001
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:3916:genAnd *{*
    ;; ***  genAnd  3917
    ;;  694 register type nRegs=2
    ;;  694 register type nRegs=2
    ;;  line = 3952 result AOP_REG=r0x104A, size=2, left AOP_REG=r0x104A, size=2, right AOP_LIT=0x1f, size=2
    ;; >>> gen.c:4131:genAnd
        MOVLW   0x1f
    ;; >>> gen.c:4133:genAnd
    ;;  1108 rIdx = r0x104A 
        ANDWF   r0x1000,F
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:7101:genCast *{*
    ;; ***  genCast  7102
    ;;  694 register type nRegs=2
    ;; ***  aopForSym 315
    ;;  327 sym->rname = _TRISB, size = 1
    ;;  line = 7110 result AOP_DIR=_TRISB, size=1, left -=-, size=0, right AOP_REG=r0x104A, size=2
    ;; ***  genCast  7234
    ;; >>> gen.c:7258:genCast
    ;;  1108 rIdx = r0x104A 
        MOVF    r0x1000,W
    ;; >>> gen.c:7259:genCast
    ;;  1009
    ;;  1028  _TRISB   offset=0
        BANKSEL _TRISB
        MOVWF   _TRISB
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2757:genLabel *{*
    ;; ***  genLabel  2760
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2522:genEndFunction *{*
    ;; ***  genEndFunction  2524
        RETURN  
    ; exit point of _set_handshake
    ;;; gen.c:7407:genpic14Code *{*
    ;***
    ;  pBlock Stats: dbName = C
    ;***
    ;entry:  _set_data  ;Function start
    ; 2 exit points
    ;has an exit
    ;2 compiler assigned registers:
    ;   r0x1000
    ;   r0x1001
    ;; Starting pCode block
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2757:genLabel *{*
    ;; ***  genLabel  2760
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2339:genFunction *{*
    ;; ***  genFunction  2341 curr label offset=0previous max_key=0 
    _set_data   ;Function start
    ; 2 exit points
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:7101:genCast *{*
    ;; ***  genCast  7102
    ;; ***  aopForSym 315
    ;;  327 sym->rname = _TRISC, size = 1
    ;;  694 register type nRegs=2
    ;;  line = 7110 result AOP_REG=r0x1048, size=2, left -=-, size=0, right AOP_DIR=_TRISC, size=1
    ;; >>> gen.c:7279:genCast
    ;;  1009
    ;;  1028  _TRISC   offset=0
        .line   8; "hd44780.c"  LCD_DATA_ADDR &= mask;
        BANKSEL _TRISC
        MOVF    _TRISC,W
    ;; >>> gen.c:7280:genCast
    ;;  1108 rIdx = r0x1048 
        BANKSEL r0x1000
        MOVWF   r0x1000
    ;; ***  addSign  826
    ;;; genarith.c:827:addSign *{*
    ;; >>> genarith.c:846:addSign
    ;;  1108 rIdx = r0x1049 
    ;;1 CLRF    r0x1001
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:3916:genAnd *{*
    ;; ***  genAnd  3917
    ;;  694 register type nRegs=2
    ;;  694 register type nRegs=2
    ;;  line = 3952 result AOP_REG=r0x1048, size=2, left AOP_REG=r0x1048, size=2, right AOP_LIT=0x0f, size=2
    ;; >>> gen.c:4131:genAnd
        MOVLW   0x0f
    ;; >>> gen.c:4133:genAnd
    ;;  1108 rIdx = r0x1048 
        ANDWF   r0x1000,F
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:7101:genCast *{*
    ;; ***  genCast  7102
    ;;  694 register type nRegs=2
    ;; ***  aopForSym 315
    ;;  327 sym->rname = _TRISC, size = 1
    ;;  line = 7110 result AOP_DIR=_TRISC, size=1, left -=-, size=0, right AOP_REG=r0x1048, size=2
    ;; ***  genCast  7234
    ;; >>> gen.c:7258:genCast
    ;;  1108 rIdx = r0x1048 
        MOVF    r0x1000,W
    ;; >>> gen.c:7259:genCast
    ;;  1009
    ;;  1028  _TRISC   offset=0
        BANKSEL _TRISC
        MOVWF   _TRISC
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2757:genLabel *{*
    ;; ***  genLabel  2760
    ;;; gen.c:2315:resultRemat *{*
    ;;; gen.c:2522:genEndFunction *{*
    ;; ***  genEndFunction  2524
        RETURN  
    ; exit point of _set_data
    ;;; gen.c:7407:genpic14Code *{*
    ;   code size estimation:
    ;      26+    9 =    35 instructions (   88 byte)
        end
    
     
  • Raphael Neider

    Raphael Neider - 2013-01-21

    You may want to disable analog input option on PORTB<7:5>:

    ANSELH &= 0b00011111;
    

    to prevent any strange readings from these pins - but, according to the data sheet, this should not affect output functionality.
    You do

    TRISB &= 0x0b00011111;
    

    to turn PORTB<7:5> into outputs in set_handshake() and you do call set_handshake(), so this is fine. (You may ensure this by setting up TRISB right before changing PORTB<5>, again.)

    Basically, I am out of ideas.
    The generated code looks pretty good to me.
    A simulation bug seems unlikely, since you tested with two (different?) simulators already.

    Do you have real hardware available to test?

    What happens if you swap code lines around? Try turning

    LCD_RS = 1; // RB5
    LCD_RW = 1; // RB6
    LCD_EN = 1; // RB7
    

    into

    LCD_RW = 1; // RB6
    LCD_RS = 1; // RB5
    LCD_EN = 1; // RB7
    

    and see what happens.
    Try writing 0 to the bits and see what happens.
    Try writing 0 to PORTB after you have set it to 0xFF.

    How do you verify that PORTB<5> remains 0? Do single step over the instruction and look at PORTB? If you inspect the port value, the simulated analog input option (see ANSELH above) might bite you. But then again, you stated that

    PORTB = 0b11100000;
    

    actually does change PORTB<5> …

    I'd love to see this verified (or falsified) on real hardware …

    Good luck,
    Raphael

     
  • Anonymous - 2013-01-23

    The use of

    ANSELH &= 0b00011111;
    

    did the trick :D
    Currious! I was setting the TRISB of the three pins to output in the hd44780.c …

    void set_handshake( void ) { 
        unsigned int mask; 
        mask = ~HAND_MASK; 
        LCD_HAND_ADDR &= mask;
    }
    

    Thanks, leaned something here! Keep up the good work!

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks