TODOPIC
Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: jaimearmandofc en 26 de Julio de 2011, 21:31:34
-
tengo problemas para trabajar con este pic, lo que deseo es lo siguiente:
usar un pic 18f4550
trabajarlo con su oscilador interno a 4mhz (o la frecuencia que me recomienden)
usar el puerto D para conectar la LCD [16x2]
lo he realizado en PCWHD
y la simulacion en Proteus me lanza lo siguiente:
Attemped to read after writing a single nibble
controller received command whilst busy
el codigo que he hecho es el siguiente,
#include <18F4550.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES PLL1 //No PLL PreScaler
#FUSES CPUDIV1 //No System Clock Postscaler
#FUSES INTEC //Internal Clock, EC used by USB
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=20000000)
#include <lcd.c>
#define LCD_DB4 PIN_D4
#define LCD_DB5 PIN_D5
#define LCD_DB6 PIN_D6
#define LCD_DB7 PIN_D7
#define LCD_RS PIN_D1
#define LCD_RW PIN_D2
#define LCD_E PIN_D0
void main(){
while(true){
lcd_init();
delay_ms(1000);
lcd_gotoxy(1,1);
printf(lcd_putc,"\fHola");
lcd_gotoxy(1,2);
printf(lcd_putc,"Holaaaaa!!!!1");
delay_ms(1000);
}
}
-
Hola, algunas correcciones, en adc no le puedes poner 16, ya que este pic tiene un ADC de 10 bits solamente. para usae el oscilador interno te falte ponerle su fuse
#fuse intrc_iolos pines de la lcd los tienes que definir antes de incluir la libreria
y el lcd_init() no necesitas ponerlo dentro de tu while ya que solo necesitas inicializar una vez tu lcd
-
gracias por tu pronta respuesta, lo que pasa es que estoi empezando a usar el PCW, porque quiero mejorar unproyecto que hice, un control para acuario, que programe en mikroc,
ire avanzando y te comento, gracias
-
ya realice los cambios mencionados pero me marca un error:
unknow keyword in #fuses "INTRC_IO"
#include <18F4550.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES PLL1 //No PLL PreScaler
#FUSES CPUDIV1 //No System Clock Postscaler
#FUSES intrc_io //Internal Clock, EC used by USB
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=20000000)
#define LCD_DB4 PIN_D4
#define LCD_DB5 PIN_D5
#define LCD_DB6 PIN_D6
#define LCD_DB7 PIN_D7
#define LCD_RS PIN_D1
#define LCD_RW PIN_D2
#define LCD_E PIN_D0
#include <lcd.c>
void main(){
lcd_init();
while(true){
delay_ms(1000);
lcd_gotoxy(1,1);
printf(lcd_putc,"\fHola");
lcd_gotoxy(1,2);
printf(lcd_putc,"Holaaaaa!!!!1");
delay_ms(1000);
}
}
-
intenta con este codigo
#include <18F4550.h>
#device adc=10//EL CONVERTIDOR ES DE 10 BITS
#FUSES NOWDT //No Watch Dog Timer
//#FUSES WDT128 //esta linea se la quite porque arriba le dices que sin wdt
#FUSES PLL1 //No PLL PreScaler
#FUSES CPUDIV1 //No System Clock Postscaler
#FUSES INTRC_IO //Internal Clock, EC used by USB
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=8000000)//EL OSC INTERNO TRABAJA A 8MHZ
#define LCD_DB4 PIN_D4
#define LCD_DB5 PIN_D5
#define LCD_DB6 PIN_D6
#define LCD_DB7 PIN_D7
#define LCD_RS PIN_D1
#define LCD_RW PIN_D2
#define LCD_E PIN_D0
#include <lcd.c>
void main(){
lcd_init();
while(true){
delay_ms(1000);
lcd_putc("\f");
lcd_gotoxy(1,1);
printf(lcd_putc,"Hola");
lcd_gotoxy(1,2);
printf(lcd_putc,"Holaaaaa!!!!1");
delay_ms(1000);
}
}
-
en varios proyectos e tenido q utilizar la lcd por el puerto d, lo q hice fue hacer algunos cambios en la libreria lcd.c, solo tienes q cambiar las direcciones y eso es todo. me jala super bien tanto en simulacion como en fisico