Estou tentando compilar um código muito simples para escrever no lcd. O código compilar no CCS, no proteus eu consigo simular o circuito normalmente, entretanto quando monto no protoboard, o pic não funciona...

#include <18f4550.h>

#FUSES NOWDT //Watch Dog Timer //No Watch Dog Timer
#FUSES HSPLL //High Speed Crystal/Resonator with PLL enabled
#FUSES NOPROTECT //Code not protected from reading *
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection *
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOWRT //Program memory not write protected *
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOMCLR //Master Clear pin disabled
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL5 //
#FUSES CPUDIV1 //System Clock by 4
#FUSES USBDIV //USB clock source comes from PLL divide by 2
#FUSES VREGEN //USB voltage regulator enabled
#FUSES ICPRT //ICPRT enabled


#USE delay(clock=48000000)


#define LCD_ENABLE PIN_D0
#define LCD_RS PIN_D1
//#define LCD_RW_PIN PIN_b1
#define LCD_D4 PIN_D4
#define LCD_D5 PIN_D5
#define LCD_D6 PIN_D6
#define LCD_D7 PIN_D7

#include <lcd.C>

void main()
{

lcd_init();

while (true)
{
printf(lcd_putc,"\fteste");
output_high (PIN_B1);
delay_ms (500);
printf(lcd_putc,"\n18f4550");
output_low (PIN_B1);
delay_ms (500);


}
}

Exibições: 864

Responder esta

Respostas a este tópico

poste tb o esquema de ligação entre os componentes.

o pic não funciona ou não aparece nada no lcd? fez o ajuste de contraste do lcd?

inclua no código além do lcd , um led a piscar, para saber se o pic esta trabalhando.

eu normalmente p linha 16f não incluo  os"#define" para o lcd, já que a biblioteca <lcd.c> puxa tds os dados.. além do mais ali ta faltando > # define RW pin_D2

O ideal tb é simplificar esses fuses , já que se trata de um programa simples. depois vc vai incrementando conforme necessidade.

 

Talvez ajude.

Coloque um delay_ms antes da chamada da função lcd_init();

assim ficaria o main.

void main()

delay_ms (100)
lcd_init();

while (true)

printf(lcd_putc,"\fteste"); 
output_high (PIN_B1);
delay_ms (500);
printf(lcd_putc,"\n18f4550"); 
output_low (PIN_B1);
delay_ms (500);


}
}

Caro Felipe,

Existe uma linha que está comentada //#define LCD_RW_PIN PIN_b1 dando a entender que o pino RW do lcd está interligado ao pino B1. Para escrever no LCD o pino RW tem de estar em "0". Retire o comentário desta linha e faça um teste com o seguinte programa :

#define LCD_ENABLE   PIN_D0
#define LCD_RS            PIN_D1
#define LCD_RW           PIN_B1
#define LCD_D4            PIN_D4
#define LCD_D5            PIN_D5
#define LCD_D6            PIN_D6
#define LCD_D7            PIN_D7

#include <lcd.C>

void main()
  { 

  output_low(LCD_ENABLE);

  output_low(LCD_RS);

  output_low(LCD_RW);

  lcd_init();

  while (true)
    { 
    printf(lcd_putc,"\fteste"); 
    delay_ms (500);
    printf(lcd_putc,"\n18f4550"); 
    delay_ms (500);

    }
  }

Gastão

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço