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.

[PIC] PIC18F26K22 and PORTB problems with LCD

Status
Not open for further replies.

lindodv

Junior Member level 1
Junior Member level 1
Joined
Jul 4, 2014
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
121
while I'm using PORTC for LCD input, every thing is fine. but LCD is blank while I'm using PORTB. why !?

Code:
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;

void main() {


    TRISB = 0;

    Lcd_Init();                      // LCD display initialization
    Lcd_Cmd(_LCD_CURSOR_OFF);        // LCD command (cursor off)
    Lcd_Cmd(_LCD_CLEAR);             // LCD command (clear LCD)

    LCD_OUT(1 ,1 ,"HELLO");
    LCD_OUT(2 ,2 ,"222222222222");
    LCD_OUT(3 ,3 ,"333333333333");
    LCD_OUT(4 ,3 ,"444444444444");


}

534654.png
 

And ... on a PIC18 always use the LATx bites, instead of PORTx bites. Eg:
sbit LCD_D4 at LATB0_bit; // RB0_bit;
 
On a Power-on Reset, RB<5:0> are
configured as analog inputs by default and
read as ‘0’; RB<7:6> are configured as
digital inputs

MOVLB 0xF ; Set BSR for banked SFRs
MOVLW 0h ; Value for init
MOVWF ANSELB ; Enable RB<7:0> for digital i/o pins
MOVLW 0h ; Value used to
; initialize data
; direction
MOVWF TRISB ; Set RB<7:0> as outputs
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top