about avrusb library

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
rodmolina
Posts: 14
Joined: Fri Mar 27, 2009 7:33 pm

about avrusb library

Post by rodmolina » Fri Mar 27, 2009 8:05 pm

First of all.. im working on a mega328P @ 3.3v and i will use USB only for bootloading, and that means 1 time a year i guess.
Thats why i prefer to overclock the RTC instead of buying a crystal.. and as avr rtc runs on 8mhz i have read there were versions about 12,8 and 16,5mhz that will test the OSCCAL value to meet that freq.. is that allright?
but.. that speed increasing will decrease flash and eeprom life time, wouldnt it?


i have read usbdrv have to be LINKED to the base-project, but i cant do that since im working on codevisionAVR.. i tried to "include" it and correct it to fit codevision, but i still got many errors when i compile it...
any comments?

i would thank any help, i had really read a lot of this project and some variations but couldnt get my doubts out!

Byee!

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Re: about avrusb library

Post by Grendel » Sat Mar 28, 2009 2:08 am

rodmolina wrote:i have read usbdrv have to be LINKED to the base-project, but i cant do that since im working on codevisionAVR.. i tried to "include" it and correct it to fit codevision, but i still got many errors when i compile it...
any comments?

You could use AVR Studio/WinAVR to build the boot loader itself, load it and then use the boot loader to flash your application.

rodmolina
Posts: 14
Joined: Fri Mar 27, 2009 7:33 pm

Re: about avrusb library

Post by rodmolina » Wed Apr 01, 2009 7:52 pm

Great! you are right i didnt realize that possibility! :D

Now, a have been able to run the firmware, but i only get an "Could not recognize the device" from windows..

the firmware is running on boot loader section, i know because i have a LED attached at the USB.connectdevice pin an it works when i turn a switch.
also, i connected the 1,5k resistor to a pin, D- and D+ are PORTD.0 and PORTD.2(INT0) respectivelly..

here i post my settings:

Code: Select all

//At Bootloaderconfig.h
#define USB_CFG_IOPORTNAME      D
#define USB_CFG_DMINUS_BIT      0
#define USB_CFG_DPLUS_BIT       2
#define USB_CFG_CLOCK_KHZ       (F_CPU/1000)

 #define USB_CFG_PULLUP_IOPORTNAME   C
 #define USB_CFG_PULLUP_BIT          0

//At MAKEFILE

DEVICE = atmega328p
BOOTLOADER_ADDRESS = 0x3800
F_CPU = 12800000
FUSEH = 0xc8
FUSEL = 0xE2



ALSO, ive read the oscillator byte and always says A3h, that was the value in the first place.. it has not been modified

guest

Re: about avrusb library

Post by guest » Thu Apr 02, 2009 1:04 am

Don't let that LED fool ya! I made the same mistake! It turns out that the atmega treats 0xff kind of like a NOP and will keep going until it hits your code(and I believe ever wrap around to 0x0000 but not sure).Another thing is when I looked up the mega328P data sheet it say the boot reset address your aiming for is at 3800. This is the address in words. You want the address in bytes. So the address should be 0x7000. I hope that helps.

rodmolina
Posts: 14
Joined: Fri Mar 27, 2009 7:33 pm

Re: about avrusb library

Post by rodmolina » Tue Apr 07, 2009 7:47 pm

you were right! my code wasnt at boot loader section.. now it is, i have checked it out with avrdude in terminal mode!

BUT.. windows still dont recognized it, i made a "dump cal" and now it seems the firm is running, since it has changed from 0xA3 to 0xC6

is there any special consideration about the hardware config? or about making it work in atmega328 or 168?
for example.. today i realized that i was connecting D+ to PD2(INT0) and D- to PD0 (RxD) so if im not wrong, the firmware has a debuggin code inside, running out through the UART so its not possible to use PD0 nor PD1. althoug i changed D- to PD4 and got the same result.. nothing

i also tried porting D+ to PC1 and D- to PC2, adding this lines in usbconfig.h:

Code: Select all

 #define USB_INTR_CFG            PCICR 
 #define USB_INTR_CFG_SET        0x02           //((1 << ISC00) | (1 << ISC01))
 #define USB_INTR_CFG_CLR        0
 #define USB_INTR_ENABLE         PCMSK1
 #define USB_INTR_ENABLE_BIT     (1 << PCINT9)
 #define USB_INTR_PENDING        PCIFR
 #define USB_INTR_PENDING_BIT    PCIF1


i cant believe it doesnt work with me! i wonder how too many people got it running so easily.. :evil:

rodmolina
Posts: 14
Joined: Fri Mar 27, 2009 7:33 pm

Re: about avrusb library

Post by rodmolina » Wed Apr 08, 2009 8:26 pm

i had tried recently with MOUSE_HID example, with no success..

i will try with a crystal as a last resource.. i have the feeling that my avr is not running at a RC calibrated 12,8Mhz

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: about avrusb library

Post by christian » Sat Apr 11, 2009 2:36 pm

You need the latest version of bootloadHID for 12.8 MHz because all other boot loaders won't fit. And you need to wire D- to the interrupt because the continuous oscillator synchronization code is used.

rodmolina
Posts: 14
Joined: Fri Mar 27, 2009 7:33 pm

Re: about avrusb library

Post by rodmolina » Tue Apr 14, 2009 9:36 pm

Welll.. i have tried out with both 16Mhz and 12Mhz with 10pF capacitors and i also added the 68ohms resistors at D+ and D- lines.
No results. i have a led at deviceconnect_pin, it blinks many times and then it says again not recognized

I saw at metaboard that you were using 27pF capacitors at the crystal, but i barely think this is not a big matter, is it?

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: about avrusb library

Post by christian » Wed Apr 15, 2009 11:48 am

Let's start at the basics: Did you make sure that the fuse values are correct? In particular, there are settings to divide the clock by 8 and whether to use the internal RC oscillator. Since you can blink an LED, the processor seems to be running. Check that the clock rate is OK.

Also, the mouse example has no deviceconnect_pin. Did you add this?

rodmolina
Posts: 14
Joined: Fri Mar 27, 2009 7:33 pm

Re: about avrusb library

Post by rodmolina » Wed Apr 15, 2009 10:00 pm

sorry christian, i ve made a new post since there is no relation between the topic and my actual problem.. i thought it was correct to do it, and didnt see your reply but.. here i am now:

i have been testing my chances.. neither the atmega8535 and atmega328p works at 12,8Mhz code.
atmega8535 works at 12 and 16Mhz
atmega328p no successfull results even with same crystals

here is what i did:
always running at 3,3v
i simply took the mouse-hid project and just like it was, i compiled it and only changed the F_CPU and DEVICE on the MAKEFILE acording to the test being made.

fuses for atmega8535 CKSEL3/0
internal RC 0 1 0 0
external Xtal 1 1 1 1

fuses for atmega328p
internal RC 0 0 1 0
external Xtal 1 1 1 1

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: about avrusb library

Post by christian » Thu Apr 16, 2009 12:01 pm

I have never tried one of the AVRs with P suffix. Maybe they need additional initialization? Or have other fuse values?

If you take the HID Mouse project and change F_CPU to 12.8 MHz, it won't work. You must also add some kind of oscillator calibration and change the fuse values so that the internal RC oscillator is used without 1/8 divider. If you have a crystal, start with that and add the other features one after the other.

rodmolina
Posts: 14
Joined: Fri Mar 27, 2009 7:33 pm

Re: about avrusb library

Post by rodmolina » Wed Aug 05, 2009 4:18 pm

SOLVED POST: wrong fuses

the problem was i was using codevisionAVR to program the fuses but aparently it has wrong info about mega328P so the code was not starting at boot address..

i can use it now at 12MHz or 16MHz perfectly ;)

Thank you Christian!

Post Reply