PIC LCD Code not running on Proteus 8 -


i'm learning how program pic controllers using ccs pcwhd ide c compiler. i'm trying display message on lcd display in proteus 8 using c code.

the code i've written compiles , .hex , .cof files generated without problem. however, when try simulate code on proteus 8, see lcd screen switching on. no blinking cursor or text appears. i've triple-checked connections , proteus schematic couldn't find problems there.

i'm using pic16f877a micro-controller 4mhz external crystal lcd display i'm using lm016l (16x2 lcd display). can't understand if problem proteus, c compiler or code?

the code i've written given below:

#include <16f877a.h>        #fuses nowdt                    //no watch dog timer #fuses xt                       //crystal osc <= 4mhz pcm/pch , 3mhz 10 mhz pcd #fuses put                      //power timer #fuses noprotect                //code not protected reading #fuses nodebug                  //no debug mode icd #fuses nobrownout               //no brownout reset #fuses nolvp                    //no low voltage prgming, b3(pic16) or b5(pic18) used i/o #fuses nocpd                    //no ee protection #fuses nowrt                    //program memory not write protected  #use delay(clock=4000000)         //4mhz crystal  #use fast_io(b)  #byte adcon1=0x9f   //implementing lcd onto port b #define portb=0x06         #define lcd_enable_pin pin_b2                     #define lcd_rs_pin pin_b0 #define lcd_rw_pin pin_b1 #define lcd_data_port portb #define  lcd_data4    pin_b4                   #define  lcd_data5    pin_b5 #define  lcd_data6    pin_b6 #define  lcd_data7    pin_b7                  #define lcd_type 2        //2 line display    #include <lcd.c>      // lcd library  void main() {     set_tris_b(0x00);  //port b output    setup_adc_ports(no_analogs);    setup_adc(adc_clock_div_2);    setup_psp(psp_disabled);    setup_spi(spi_ss_disabled);    setup_timer_0(rtcc_internal|rtcc_div_1);    setup_timer_1(t1_disabled);    setup_timer_2(t2_disabled,0,1);    setup_comparator(nc_nc_nc_nc);    setup_vref(false);     //todo: user code   lcd_init();  delay_ms(10);    while (true)    {            lcd_send_byte(0,0x0e);  //blinking cursor        delay_ms(10);        printf(lcd_putc,"\fhello");        printf(lcd_putc,"\nworld");                                                   delay_ms(1000);                         printf(lcd_putc,"\fmy");                    printf(lcd_putc,"\nfirst");           delay_ms(1000);         lcd_gotoxy(5,1); //row 1, column 5        delay_ms(10);        printf(lcd_putc,"\fpic");                                lcd_gotoxy(1,2); //row 2 column 5           delay_ms(10);        printf(lcd_putc,"project");           delay_ms(1000);                                             } }      

  • you have initialise micro-controller clock (osccon), not there in given code.
  • you want disable adc used setup_adc_ports(no_analogs);

    so, next setup_adc(adc_clock_div_2); code of line not required.

  • make sure r\w pin connected ground.

  • contrast adjustment resistor should there

please check below image connections :

enter image description here

this link have code in micro c, reference


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -