about avrusb library
about avrusb library
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!
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!
Re: about avrusb library
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.
Re: about avrusb library
Great! you are right i didnt realize that possibility!
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:
ALSO, ive read the oscillator byte and always says A3h, that was the value in the first place.. it has not been modified
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
Re: about avrusb library
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.
Re: about avrusb library
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:
i cant believe it doesnt work with me! i wonder how too many people got it running so easily..
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..
Re: about avrusb library
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
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
Re: about avrusb library
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.
Re: about avrusb library
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?
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?
Re: about avrusb library
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?
Also, the mouse example has no deviceconnect_pin. Did you add this?
Re: about avrusb library
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
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
Re: about avrusb library
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.
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.
Re: about avrusb library
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!
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!