■ SCREENSHOT 3. The VDIP2 is now responding to
commands and issuing status information. We have arrived!
(bytein[1] == 0x0D)) {
status.e = 1;
}
else {
mdelay1(100);
}
}
}while((status.e == 0) &&
(sync_loops < 0xFF));
}
if(status.E && status.e)
rc = 1;
return rc;
}
A return code of 1 is passed back to the caller if the
echo and sync operations were successful. At this point,
here's what our API main() function code looks like:
//*MAIN MAIN MAIN MAIN MAIN
void main() {
init();
cleaner();
vreset();
sync();
do{
++sync_loops; //loop here forever
}while(1);
}
The HI-TECH C PRO for the PIC18 MCU family
compiler placed the PIC18LF2620's EUSART transmit
buffer at offset 0x0100 and the receive buffer at offset
0x0200 in the PIC18LF2620's SRAM. The results of the
execution of the API main() function code we've written
thus far is captured in Screenshot 1. I produced the data
in Screenshot 1 (and all subsequent screenshots) from the
MPLAB File Register views using the MPLAB IDE and a
Microchip REAL ICE in debug mode.
Believe it or not, we're one character away from
initializing the VDIP2. Let's see what happens when we
add tese two lines of code to our current API main()
function just after the sync() function call:
//*MAIN MAIN MAIN MAIN MAIN
void main() {
init();
78 January 2009
cleaner();
vreset();
sync();
cleaner();
sendchar(0x0D);
do{
++sync_loops;
}while(1);
}
I threw in a call to the "cleaner" after the synchronization
so we would get a screenshot with a fresh look at what
the carriage return did. Screenshot 2 shows that the
VDIP2 got a bit wordy. That's a good thing and the VDIP2
speaks the truth. A Flash drive is not mounted.
All we have to do to update the VDIP2's VNC1L with
new VDAP firmware is power-down the VDIP2 and
PIC18LF2620, mount a Flash drive containing the upgrade
file, power-up the VDIP2 and PIC18LF2620, and run the
API code we have written up to this point.
Remember those bargain Flash drives I bought?
Well, they don't work with the VDIP2. After a few dozen
unsuccessful attempts to upgrade the VNC1L firmware,
I resorted to a more careful read of the VDIP2 User
Manual. I came across a blurb that informed me that
some Flash drives don't follow the rules of a hard drive
and thus, won't be recognized as valid Flash drives by
the VNC1L.
After reading that, I put out an APB for a different
brand or model of Flash drive and my wife pulled one out
of her computer bag. I plugged it in and when its activity
LED stopped bouncing around, I performed a POR
(Power On Reset) of the VDIP2 hardware. I decided to
go for broke and executed the following code:
//* MAIN MAIN MAIN MAIN MAIN
void main() {
init();
cleaner();
vreset();
sync();
sendchar(0x0D);
sendchar('F');
sendchar('W');
sendchar('V');
sendchar(0x0D);
do{
++sync_loops;
}while(1);
}