>On 10 Oct 2006 08:15:27 -0700, "Mercy" <mercy.chang@gmail.com> wrote:
>
>>Hi all,
>>
>>Any advice/pointers or instructions would be most helpful. I am still
>>a newbie at embedded design so please humor me.
>>
>>I have a datalogger module written using an Atmel 8051. I want to add
>>a USB port to it so I can simply plug in a USB flash drive and have the
>>data automatically downloaded as a formatted text file.
>>
>>I have read www.usb.org... but I still don't know where to start. If
>>someone could point me to an online resource or a book... preferrably
>>something with similiar applications... that'd be great!
>
>
>Life is too short to do this yourself.
>
>Use one of these :
>http://www.vinculum.com/
>
>Or these :
>http://www.ghielectronics.com/details.php?id=1
>
Has anyone actually gotten one of these things to work?? I'm trying to
read a USB flash drive using the VDIP( Vinculum w/ VDAP firmware) through
a UART port on an MSP430F1611.
The code below is supposed to generate an interupt to when CTS#(referenced
from the uP) is asserted. The interupt asserts RTS#, and waits for the
character to come into the RX Buffer. The character is then stored into
memory. The code is also supposed to transmit a <CR> to the VDIP, this
would generate a response saying that a USB devices is or in not
connected.
The there are two problems I have noticed so far. For transmitting a
character to the VDIP, I assert the RTS# and wait for CTS# to be asserted.
Before sending a character to the VDIP over the UART. However CTS# never
goes high. The second problem is that nothing is ever recieved from the
VDIP because CTS# never goes high. And so nothingis ever transmited or
received.
The code that I'm to use to communicate with the VDIP is shown below.
;----------------------------------------------------------------------------
; Initialization Sequence
#include <msp430x14x.h>
ORG 01100h
RESET mov.w #0A00h,SP ;
Initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop
WDT
bis.b #001h, &P1DIR ; Use P1.0
as output
bic.b #001h, &P1OUT
bis.b #030h, &P3SEL ; Use P3.4,5 for UART0
bis.b #050h, &P3DIR ; Use P3.4,6 as output
bis.b #040h, &P5DIR ; Use P5.6 for DREQ
bis.b #040h, &P5OUT ;
mov.b #004h, &BCSCTL1 ; Setup Clocks
mov.b #088h, &BCSCTL2 ;
mov.b #002h, &IFG1 ;
SetOsc0 bic.b #OFIFG, &IFG1 ; Test Oscilator
mov.w #0FFh, R15 ;
SetOsc1 dec.w R15 ;
jnz SetOsc1 ;
bit.b #OFIFG, &IFG1 ;
jnz SetOsc0 ;
mov.b #021h, &U0TCTL ; Setup U0TCTL
mov.b #008h, &U0RCTL ; Setup U0RCTL
mov.b #baudDiv0, U0BR0 ; Setup Baud Rate Clock
mov.b #baudDiv1, U0BR1 ;
mov.b #baudMod, U0MCTL ;
bis.b #0C0h, &ME1 ; Enable UART Transmitters
mov.b #010h, &U0CTL ; UART0 Released
mov.b #000h, &P1IES ; Port 1: Low=>High Transition
Cause Interupts
bic.b #0FFh, &P1IFG ; Clear
any existing Port 1 Interupt Flags
mov.b #002h, &P1IE ; Allow
P1.1 to Cause Interupts
bis.b #GIE, R2 ; Enable global interupts
;----------------------------------------------------------------------------
; Super_Loop
mov.w &fromUSB, R5 ; R5 is a
pointer to a table where data is received from the UART
Super_Loop mov.w &toUSB, R4 ; R4 is pointer
to data being sent to UART
call #UART0_TX ; transmit
character subroutine
jmp Super_Loop ; Do nothing
;----------------------------------------------------------------------------
; UART0 TX Subroutine
UART0_TX bic.b #002h,&P1IE ; Disable
Interupts Caused by P1.1
bis.b #rts, &P1OUT ; Set P1.1
(RTS# on uP, #CTS on USB Host)
poll_CTS_TX bit.b #cts, &P1IN ; Wait for
CTS#(uP) to set
jz poll_CTS_TX
poll_TX bit.b #TXEPT, &U0TCTL ; Wait
until U0 TX Buffer is Empty
jz poll_TX
mov.b @R4,U0TXBUF ; Transmit
Selected Character
bic.b #rts, &P1OUT ; Reset
P1.1 (RTS# on uP, #CTS on USB Host)
bis.b #002, &P1OUT ; Enable
Interupts Caused by P1.1
ret ; return from subroutine
;--------------------------------------------------------------------------
; P1.1 Interupt Handler (for UART RX, activated on rising edge of #CTS
P1_ISR bit.b #cts, &P1IFG ; test P1_ISR Trigger
jz end_ISR ;
bis.b #rts,&P1OUT ; Set P1.1
(RTS# on uP, CTS# on Host)
poll_RX bit.b #040h, &IFG1 ; Poll
UART RX Flag until 1
jz poll_RX
mov.b &U0RXBUF, 0(R5) ; Move
RXed Char to Address pointed to by R5, post inc.
inc.b R5
end_ISR mov.b #000h, &P1IFG ; Reset All P1
Interupt Flags
bic.b #rts,&P1OUT ; Reset
P1.1 (RTS# on uP, CTS# on Host)
reti ; return from interupt
;---------------------------------------------------------------------------
; Memory
toUSB DW testDataTx ; pointer to table where data
is transmitted
fromUSB DW testDataRx ; pointer to table where data is
received
testDataTx DW 00Dh ; Data to be transmitted to USB
testDataRx DW 0, 0, 0, 0, 0, 0, 0, 0 ; Data received
from USB Host
DW 0, 0, 0, 0, 0, 0, 0, 0
;---------------------------------------------------------------------------
;Interupt Vectors
ORG 0FFFEh
DW RESET
ORG 0FFE8h
DW P1_ISR
;--------------------------------------------------------------------------
;EQUATES
baudDiv0 EQU 041h
baudDiv1 EQU 003h
baudMod EQU 000h
rts EQU 001h
cts EQU 002h
end
Any help is much appreciated.