i am using a 18F4550 and the plan is to send messages from usb to the lcd, the problem is i can not get my screen stable, can i run the pic at 20Mhz?
Any ideas would be welcome
Code:INCLUDE "MODEDEFS.BAS" DEFINE LOADER_USED 1 DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader DEFINE OSC 20 ' Define crystal as 20Mhz 'Define ACDIN parameters Define ADC_BITS 10 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source ( 3 = RC ) DEFINE ADC_SAMPLEUS 50 ' Set sampling time to micro-seconds 'This Part set PORTA 0-3 an analog inputs,4 as digital TRISA = %00011111 'set PORTA 0-5 as inputs ADCON1 = %00001010 'ADC use vss and vdd as ref. ADCON2 = %10000111 'FRC (clock derived from A/D RC oscillator),Right justify output TRISC = %10000000 TRISB = %10011000 TRISD = %00000000 '**************************************Serial port setup************************************* '*Serial port Setup 3800 8N1* DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_CLROERR 1 ' Clear overflow automatically DEFINE HSER_SPBRG 56 ' 38400 Baud @ 48MHz, -0.16% SPBRGH = 1 BAUDCON.3 = 1 ' Enable 16 bit baudrate generator '**************************************LCD setup********************************************* ' Set LCD Data port DEFINE LCD_DREG PORTD ' Set starting Data bit (0 or 4)if 4-bit bus DEFINE LCD_DBIT 0 ' Set LCD Register Select port DEFINE LCD_RSREG PORTD ' Set LCD Register Select bit DEFINE LCD_RSBIT 5 ' Set LCD Enable port DEFINE LCD_EREG PORTD ' Set LCD Enable bit DEFINE LCD_EBIT 4 ' Set LCD bus size (4 or 8 bits) DEFINE LCD_BITS 4 ' Set number of lines on LCD DEFINE LCD_LINES 2 ' Set command delay time in us DEFINE LCD_COMMANDUS 2000 ' Set data delay time in us DEFINE LCD_DATAUS 50 '**************************************Variables********************************************* buffer Var Byte[70] cnt Var Byte LED Var PORTD.4 CELL1 var byte[70] i var byte USBInit Low LED ' LED off '**************************************Main Program****************************************** LCDOUT $FE,1 PAUSE 1000 main: LCDOUT $FE,2 LCDOUT "line 1" LCDOUT $FE, $C0 LCDOUT "line 2" PAUSE 1000 goto main END
Bookmarks