Page 1 of 1

USB to SPI with ATMEL16

Posted: Sun Oct 09, 2011 6:23 am
by ardiansyah_mrit
hey.. morning all :D
can you help me about that topic??
i'm using v-usb to create that project but i don't know how to use the frimware in v-usb.. :cry:
i'm want to write / read eeprom via usb using SPI protocol.
please help me this my final project in my education... :(

Re: USB to SPI with ATMEL16

Posted: Sun Oct 09, 2011 8:29 pm
by maxi
Something like this perhaps http://www.recursion.jp/avrcdc/cdc-spi.html?

There is a version for mega8, shouldn't be too difficult to compile for mega16.

Re: USB to SPI with ATMEL16

Posted: Mon Oct 10, 2011 5:26 am
by ardiansyah_mrit
thank's form reply :) , but i'm still confius about that. :(
i want to write and read the eeprom (AT93c465) via USB from my PC.
i'm using v-usb last update, in the source i'm confused how to edit the source so i can write and read the eeprom (AT93c46) from PC via USB PORT using SPI comunication in ATMEGA16..

please help me on the source bellow :
main.c on D:\vusb-20100715\examples\hid-data\firmware
uchar usbFunctionRead(uchar *data, uchar len)
{
if(len > bytesRemaining)
len = bytesRemaining;
eeprom_read_block(data, (uchar *)0 + currentAddress, len); //how to change this line, so i can read the EEPROM from PC via USB Port
currentAddress += len;
bytesRemaining -= len;
return len;
}

/* usbFunctionWrite() is called when the host sends a chunk of data to the
* device. For more information see the documentation in usbdrv/usbdrv.h.
*/
uchar usbFunctionWrite(uchar *data, uchar len)
{
if(bytesRemaining == 0)
return 1; /* end of transfer */
if(len > bytesRemaining)
len = bytesRemaining;
eeprom_write_block(data, (uchar *)0 + currentAddress, len); //how to change this line, so i can write the EEPROM from PC via USB Port
currentAddress += len;
bytesRemaining -= len;
return bytesRemaining == 0; /* return 1 if this was the last chunk */
}


and this my block diagram of my project :
PC to ATMEGA16 using USB, ATMEGA to EEPROM (AT93C46) module using SPI PORT