USB VNC1L module
Project definition
Main task is to create universal C library for microprocessors (ATmega, MSP340, ARM7) which will communicate with VNC1L module. VNC1L module is USB host giving the possibility to connect any USB device (Flash Disc, web camera, etc) to microprocessors which have not integrated USB. The library will be programmed by connecting USB data disc and VNC1L to ATmega microprocessor with SPI and UART interface.
Vinculum VNC1L USB host controller (VDIP1 - DIP format of the VNC1L)
The device transparently handles the FAT file structure communicating via UART, SPI or parallel FIFO interfaces via a simple to implement command set (Monitor port). The VNC1L device features two USB Ports which can be individually configured by firmware as Host or Slave ports. The device has two USB host ports as well as a combined UART, SPI or FIFO interface. Command Monitor port can be activated on either the combined interface or one of the USB ports.
Flash disks are connected to VNC1L through the VDIP1 module which is MCU to USB host controller development module for the VNC1L device. It is supplied on a PCB designed to fit a 24-pin DIP socket and provides access to all UART, SPI and FIFO interface pins of the VNC1L device. It is ideal for rapid prototyping and development of VNC1L designs. An attractive quantity discount structure also makes this module suitable for incorporation into low/medium volume finished product designs.
I use 'AVR Studio' from ATMEL to program the C library (download AVR Studio).
Developing phase


Reprograming the VNC1L Flash memory with a new firmware:
In order to communicate with the VNC1L, it is required to choose firmware and to reprogram its Flash memory. In our case, the more adapted one is ‘VDAP Firmware’ which is used to provide USB Host functionality to a microcontroller. This will have the monitor port on the combined interface allowing BOMS devices (Bulk Only Mass Storage, e.g. Flash Disk) to be connected to Port 2 and USB Slave Peripherals to Port 1 as shown beside on 'Fig.1'.
Actually the VDIP1 device is sold with a preloaded ‘VDAP Firmware’ but it is an old version.
However, it is quite easy to reprogram the VNC1L Flash memory with new firmware via the UART
interface using the VNC1L-1A's internal bootloader.
To do so, start by downloading new firmware and the VPROG application availables as free downloads from the Vinculum web site (download new firmware and VPROG application) and install Windows CDM (D2XX) drivers (download Windows CDM (D2XX) drivers) in order to use an FTDI 232 (USBUART) device. It is possible to use other devices with a UART, but these will require a different application which must be written by the developer.
Once it is done, just connect the FTDI 232 device with the VNC1L as shown on 'Fig.2' beside, link the FTDI 232 device to the computer and run the VPROG application following the steps explained on the 'VPROG VNC1L reflasher application manual' provided with the VPROG application until a message box is displayed indicating that the reprogramming has completed and was successful.


Communication between ATmega88 and VNC1L:
Communication through SPI protocol:
Both devices exchange data through a SPI protocol. They are linked to each other as shown beside on 'Fig.3'.
I/O on data and control bus pins of the VDIP1 are configured in SPI mode using J3 and J4 three way jumper pin headers (J3 pull down ACBUS5 and J4 pull up ACBUS6).
Communication through UART protocol:
Both devices exchange data through a UART protocol. They are linked to each other as shown beside on 'Fig.4'.
I/O on data and control bus pins of the VDIP1 are configured in UART mode using J3 and J4 three way jumper pin headers (J3 pull up ACBUS5 and J4 pull up ACBUS6).
The software is loaded on ATmega88 through its /RESET pin using an AVR Dragon interface which also provides the power supply unit (5V0 / GND).
Communication with MSP430 microcontroler:

In order to communicate with VNC1L from MSP430 microcontroler, I had to create the following module adding a 4 MHz oscillator and giving access to all I/O port pins:
ORCAD schematic of the MSP430 module
The library:
I have created several functions allowing from ATmega88 to manage data into a flash disk plugged to VDIP1 device:
int init (unsigned int ubrr) Initialize the ATmega88 to communicate through SPI or UART protocol.
char receive () Receive a byte from VNC1L via SPI or UART and return it as a ‘char’ value.
int recept_sentence (char Sentence[], int Length) Receive several bytes from VNC1L and write them into the ‘char’ chain given as parameter until a single carriage return (0x0D) or a null value (0x00) is received or until the ‘char’ chain is full.
int check_prompt (char Sntce1[]) Check if the last sentence received was a prompt (D:\>) and return 0 if it was.
int wait_prompt () Receive sentences from VNC1L until a prompt reception.
unsigned int transmit (char cData) Send a byte as a ‘char’ value to VNC1L through SPI or UART protocol.
int trans_command (char * pCommand) Send several bytes as ‘char’ values from the address given as parameter until a null value is read but not sent and add a single carriage return in the end.
int trans_data (char * pData) Send several bytes as ‘char’ values from the address given as parameter until a null value is read but not sent.
int convert_dword (unsigned long Number, char dWord []) Convert a ‘long’ value given as parameter into a ‘char’ chain and write it to the given address.
int execute_one (char My_Command[]) Send the command given as parameter and wait for VNC1L to send a prompt.
int execute_two (char My_Command1[], char My_Command2[]) Send the command given with the two parameters and wait for VNC1L to send a prompt.
int execute_dword (char My_Command[], char My_dWord[]) Send the command given as first parameter followed by the value given into the second one.
int write_sentence (char Sentence[]) Write the given 'char' chain into the current opened file and wait for VNC1L to send a prompt.
int write_file (char My_Data[], char My_File[]) Open the file named by the second given parameter (or created if it did not exist yet) and write the 'char' chain given as first parameter at its end before to close it.
int read_file (char My_File[]) Open the file named by the given parameter and read it before to close it.
Results
The software:
Using the library, it becomes easy to communicate with VNC1L (sending commands and receiving data sent back) and in this way we can manage data into a flash disk plugged on VDIP1 device. Here follows an example of communication.
// Initialize ATmega88 init(); // Receive data sent by VNC1L waiting for a prompt reception wait_prompt(); // Upon starting the Monitor, the following string is displayed indicating the firmware version number (02.08) and the firmware type (VDAP) loaded on VNC1L Ver 02.08VDAPF On-Line: // While a device is not detected VNC1L does not send new data ........................ ........................ ...... // As soon as a device is plugged on USB Port 2, the following string is displayed Device Detected P2 // And no new data is sent while the device is scanned ........................ ........................ ...... // When the scan disk is over, the following strings are displayed No Upgrade D:\> // ATmega88 is now able to send a command like ‘DIR’ for example execute_one ("DIR"); // VNC1L lists files in current directory SUBDIR1 DIR SUBDIR2 DIR FILE1.XXX FILE2.XXX D:\> // ATmega88 can also write data into a file on the flash disk write_file ("HELLO!", "NEW.TXT"); // VNC1L answer when it is ready for more commands D:\> // ATmega88 can write more data into the same file without overwriting the previous ones write_file ("HOW ARE YOU?", "NEW.TXT"); // VNC1L answer when it is ready for more commands D:\> // ATmega88 can read this file read_file("NEW.TXT");); // VNC1L send data contained in this file (the '.' = '0x0A' indicates a new line) HELLO! .HOW ARE YOU? D:\>
Notes :
The ‘’ character represent a single carriage return.
When ATmega88 reads data sent by VNC1L waiting for it to be ready to receive an other command while it is not sending new data, the software returns null characters '0x00' (......).
A prompt (D:\>) is sent when VNC1L is ready for a new command.
Documentation
- VNC1L_Datasheet
- VDIP1_Datasheet
- VDIP1_Schematic
- VNC1L_FirmwareUserManual
- ATmega88_Datasheet
- MSP430F169 Datasheet