PDA

View Full Version : VDIP1 and 16f688 HSEROUT



emerson
- 7th February 2013, 21:34
I finally got around to setting up my VDIP1 and I have no clue where to start. I have it connected to a 16f688 and am using the onboard serial communication ports and HSEROUT commands with 9600 baud rate. The VDIP1 is set in UART mode and CTS pin 10 is grounded. When I turn my circuit on the VDIP1 leds alternate two or three times, stop, then alternate once again. At this point led 2 begins to flash as does the USB thumb drive internal led. Once that stops led 2 remains on. It seems the VDIP1 recognizes the thumb drive based on what I just explained. The thumb drive I am using is a Verbatim 4gb card formatted in FAT32.

My problem is communicating with the module. Here is my code so far, though I feel it is lacking some essential features:



ANSEL = 0
TRISC = 0
CMCON0 = 0

DEFINE LCD_DREG PORTC 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 0 'LCD Data Starting Bit = Bit 0 or 4
DEFINE LCD_EREG PORTA 'Define PIC port used for E line of LCD
DEFINE LCD_EBIT 5 'Define Port pin used for E connection
DEFINE LCD_RSREG PORTA 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 4 'Define Port pin used for RS connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.

Pause 600 ' Wait for LCD to startup

DEFINE HSER_RCSTA 90h ' Enable Serial PORT
DEFINE HSER_TXSTA 24h ' Enable transmit
DEFINE HSER_SPBRG 129 ' set USART to 9600 baud (when BRGH=1)
DEFINE HSER_CLROERR 1 ' Enable automatic overrun error
DEFINE LOADER_USED 1

Receive var word

'~~~~~~~~~~Main Proram~~~~~~~~~~~~~~~~~~~~~~~

lcdout "Start"

Main:

pause 2000
lcdout $fe, 1

hserout ["SCS", $0D] 'select shorthand command set
pauseus 10
hserout ["IPA", $0D] 'input in ASCII
pauseus 10
hserout [$01, $0D] 'list files in current directory

pauseus 10
hserin [receive]
lcdout receive
pause 100

stop


There is a file on the thumb drive named "A" and I am trying to have that filename displayed on an lcd screen. The connection between the lcd and the pic works fine, but once the lcd screen is cleared it remains blank. Can anyone help get me started in the right direction? Thanks

p.s. I have seen BrianT's write-up on using the VDIP1 module and tried to use what he did in the beginning

emerson
- 7th February 2013, 22:23
here are the datasheets for the 16f688, VDIP1, and the command codes for the VDIP1:

16f688 datasheet - http://ww1.microchip.com/downloads/en/devicedoc/41203d.pdf

VDIP1 datasheet - http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_VDIP1.pdf

VDIP1 commands - http://www.ftdichip.com/Firmware/Precompiled/UM_VinculumFirmware_V205.pdf

Darrel Taylor
- 8th February 2013, 18:14
Your HSER defines are setup for 9600 baud at 20Mhz.
But you don't have a DEFINE OSC statement, so PBP assumes you are running at 4Mhz.

What frequency is your oscillator?

emerson
- 8th February 2013, 18:32
wow I sure missed that. I typically use the 8MHz internal oscillator because I have no external crystals to use.