LCD PIC18F4455 con mplabx xc8

Hola disculpen estoy tratando de realizar un proyecto empleando el mplabx para un pic18f4455 y para ello necesito emplear la libreria LCD, he realizado varios ejemplos con otros modelos de pic menos potentes y no he tenido problema en hacerlos funcionar pero con este de verdad que si me he desesperado, cada vez que lo intento programar empleando el oscilador interno me sale la siguiente leyenda en proteus: Controller reiceived command whilst busy. Considero que es por el hecho de que no programo bien los relojes del pic espero que alguien me pueda ayudar les dejo es codigo para ver si puden detectar mi error. gracias:


#include <xlcd.h> //incluimos biblioteca para manejo de lcd
#include <stdio.h> //incluimos biblioteca para manejo de caracteres
#include <stdlib.h> //incluimos biblioteca para manejo de string
#include <xc.h> //incluimos biblioteca general
#include <delays.h> //incluimos biblioteca para retardos
#include <stdbool.h> //incluimos biblioteca para uso de boleanos

#define _XTAL_FREQ 8000000 //agregamos el valor del oscilador a utilizar

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

// CONFIG1L
#pragma config PLLDIV = 1
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 1

#pragma config FOSC = INTOSCIO_EC
#pragma config FCMEN = OFF
#pragma config IESO = OFF

// CONFIG2L
#pragma config PWRT = ON
#pragma config BOR = OFF // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 3 // Brown-out Reset Voltage bits (Minimum setting)
#pragma config VREGEN = OFF // USB Voltage Regulator Enable bit (USB voltage regulator disabled)

// CONFIG2H
#pragma config WDT = OFF // Watchdog Timer Enable bit (WDT enabled)
#pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)

// CONFIG3H
#pragma config CCP2MX = ON // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBADEN = ON // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config LPT1OSC = ON // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
#pragma config MCLRE = OFF // MCLR Pin Enable bit (RE3 input pin enabled; MCLR pin disabled)

// CONFIG4L
#pragma config STVREN = OFF // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = OFF // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config ICPRT = OFF // Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit (ICPORT disabled)
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

// CONFIG5L
#pragma config CP0 = OFF // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
#pragma config CP1 = OFF // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
#pragma config CP2 = OFF // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)

// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)

// CONFIG6L
#pragma config WRT0 = OFF // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
#pragma config WRT1 = OFF // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
#pragma config WRT2 = OFF // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)

// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)

// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF

void DelayFor18TCY( void )
{_delay(18);}

void DelayPORXLCD (void){
__delay_ms(15);
}

void DelayXLCD (void){
__delay_ms(5);
}

void main(void) {

OpenXLCD(FOUR_BIT&LINES_5X7); //configure LCD in 4-bit Data Interface mode

SetDDRamAddr(0x40);

while(BusyXLCD()); //Check if the LCD controller is not busy

WriteCmdXLCD(0x06); // move cursor right, don?t shift display

while(BusyXLCD()); //Check if the LCD controller is not busy

WriteCmdXLCD(0x0C); //turn display on without cursor

while(BusyXLCD()); //Check if the LCD controller is not busy

putrsXLCD("Hello World"); //Display "Hello World"

while(1){}

return;
} ...
 
Atrás
Arriba