hid-data on tiny45
hid-data on tiny45
Hi there,
I've tried to get the hid-data example on a tiny45. I used some parts of the Easylogger project to adopt it to the tiny, also the OSC-Calibration.
The device is recognized properly, I can see it in the device manager - also bushound sees the device with correct descriptor and definitions
BUT: It's not possible to exchange data with the device. Also when I replace the EEProm-Access with dummy values it doesn't work.
Now, to see if the host software is compiled correctly, I ported the source to the atmega8 - where it works like a charm.
Does anybody know if there's a incompatibility between hid-data and the tiny45 or has someone ported that example successfully to the tiny45?
I don't have access to my source right now - I can upload it by tomorrow.
best wishes,
chris
I've tried to get the hid-data example on a tiny45. I used some parts of the Easylogger project to adopt it to the tiny, also the OSC-Calibration.
The device is recognized properly, I can see it in the device manager - also bushound sees the device with correct descriptor and definitions
BUT: It's not possible to exchange data with the device. Also when I replace the EEProm-Access with dummy values it doesn't work.
Now, to see if the host software is compiled correctly, I ported the source to the atmega8 - where it works like a charm.
Does anybody know if there's a incompatibility between hid-data and the tiny45 or has someone ported that example successfully to the tiny45?
I don't have access to my source right now - I can upload it by tomorrow.
best wishes,
chris
Re: hid-data on tiny45
Just to confirm I have successfully had both of those examples running on my ATtiny45 so it certainly can be done.
I have no idea what could be causing your particular problem but i'd guess that its something minor that you have simply overlooked.
Perhaps when you post your sources someone will spot it.
I have no idea what could be causing your particular problem but i'd guess that its something minor that you have simply overlooked.
Perhaps when you post your sources someone will spot it.
-
- Rank 1
- Posts: 21
- Joined: Wed Dec 30, 2009 3:24 pm
Re: hid-data on tiny45
maxi wrote:Just to confirm I have successfully had both of those examples running on my ATtiny45 so it certainly can be done.
I have no idea what could be causing your particular problem but i'd guess that its something minor that you have simply overlooked.
Perhaps when you post your sources someone will spot it.
Hi Maxi, what did you change when you adapted easylogger to hid-data example?
Because I have the same problem: easylogger works, but hid-data example based on easylogger doesn't work.
Re: hid-data on tiny45
vsovereign wrote:what did you change when you adapted easylogger to hid-data example?
Sorry, that was a while back and I no longer have the code but IIRC very little change was required. Really more a matter of adapting the hid-data exampe for ATtiny45 not really anything to do with easylogger other than copying the pin configs etc.
So just get a fresh copy of the hid-data example, edit the makefile (DEVICE, FUSE_L & FUSE_H), edit usbconfig.h (port/pin configs)
Add OSCCAL from libs-device and that should be about all there is to it.
-
- Rank 1
- Posts: 21
- Joined: Wed Dec 30, 2009 3:24 pm
Re: hid-data on tiny45
maxi wrote:vsovereign wrote:what did you change when you adapted easylogger to hid-data example?
So just get a fresh copy of the hid-data example, edit the makefile (DEVICE, FUSE_L & FUSE_H), edit usbconfig.h (port/pin configs)
Add OSCCAL from libs-device and that should be about all there is to it.
Hey Maxi, I tried to add OSCCAL and call it from the main function of HID_DATA.
So far it doesn't work. But I might have call OSCCAL the wrong way.
This is the OSCCAL as I put it into the main program and in the main program is how I call it, what do you think?
Code: Select all
/* -----------------------------------------------------------------------------*/
static void calibrateOscillator(void)
{
uchar step = 128;
uchar trialValue = 0, optimumValue;
int x, optimumDev, targetValue = (unsigned)(1499 * (double)F_CPU / 10.5e6 + 0.5);
/* do a binary search: */
do{
OSCCAL = trialValue + step;
x = usbMeasureFrameLength(); // proportional to current real frequency
if(x < targetValue) // frequency still too low
trialValue += step;
step >>= 1;
}while(step > 0);
/* We have a precision of +/- 1 for optimum OSCCAL here */
/* now do a neighborhood search for optimum value */
optimumValue = trialValue;
optimumDev = x; // this is certainly far away from optimum
for(OSCCAL = trialValue - 1; OSCCAL <= trialValue + 1; OSCCAL++){
x = usbMeasureFrameLength() - targetValue;
if(x < 0)
x = -x;
if(x < optimumDev){
optimumDev = x;
optimumValue = OSCCAL;
}
}
OSCCAL = optimumValue;
}
/* ------------------------------------------------------------------------- */
int main(void)
{
uchar i;
uchar calibrationValue;
wdt_enable(WDTO_1S);
calibrationValue = eeprom_read_byte(0); /* calibration value from last time */
if(calibrationValue != 0xff){
OSCCAL = calibrationValue;
}
/* Even if you don't use the watchdog, turn it off here. On newer devices,
* the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
*/
//DBG1(0x00, 0, 0); /* debug output: main starts */
/* RESET status: all port bits are inputs without pull-up.
* That's the way we need D+ and D-. Therefore we don't need any
* additional hardware initialization.
*/
//odDebugInit();
usbInit();
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
i = 250;
while(--i){ /* fake USB disconnect for > 250 ms */
wdt_reset();
_delay_ms(1);
}
usbDeviceConnect();
sei();
//DBG1(0x01, 0, 0); /* debug output: main loop starts */
for(;;){ /* main event loop */
// DBG1(0x02, 0, 0); /* debug output: main loop iterates */
wdt_reset();
usbPoll();
}
return 0;
}
/* ------------------------------------------------------------------------- */
Re: hid-data on tiny45
Hi, for OSCCAL all you really need to do is modify usbconfig.h something like this, in the relevant section.
Read osccal.h for more information where you will need to 'un-comment' this section:
All the necessary code is in osccal.c so no need to copy it into your main program. You will ofcourse need to add the path to libs-device to your project's makefile.
Code: Select all
*/
#if USB_CFG_CLOCK_KHZ==16500
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 1
#include "osccal.h"
#else
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
#endif
/* define this macro to 1 if you want the function usbMeasureFrameLength()
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
*/
Read osccal.h for more information where you will need to 'un-comment' this section:
Code: Select all
#ifndef __ASSEMBLER__
#include <avr/interrupt.h> // for sei()
extern void calibrateOscillator(void);
#endif
#define USB_RESET_HOOK(resetStarts) if(!resetStarts){cli(); calibrateOscillator(); sei();}
All the necessary code is in osccal.c so no need to copy it into your main program. You will ofcourse need to add the path to libs-device to your project's makefile.
-
- Rank 1
- Posts: 21
- Joined: Wed Dec 30, 2009 3:24 pm
Re: hid-data on tiny45
hi Maxi, I managed to connect the device to the host.
I put #include "osccal.h" in the usbconfig.h just like you showed.
the device is now recognized by the host.
but now I have trouble trying to communicate with the device.
I buuilt the host software according to the readme file
but when I tried to create the makefile it says that in usbconfig.h the osccal.h file can't be found and failed.
I tried this before when the device was still couldn't be connected and that time everything worked fine.
any ideas how to test if any communication can be done between the device & the host?
thanks!
I put #include "osccal.h" in the usbconfig.h just like you showed.
the device is now recognized by the host.
but now I have trouble trying to communicate with the device.
I buuilt the host software according to the readme file
BUILDING THE HOST SOFTWARE
==========================
Make sure that you have libusb (on Unix) or the DDK (on Windows) installed.
We recommend MinGW on Windows since it includes a free version of the DDK.
Then change to directory "commandline" and run "make" on Unix or
"make -f Makefile.windows" on Windows.
but when I tried to create the makefile it says that in usbconfig.h the osccal.h file can't be found and failed.
I tried this before when the device was still couldn't be connected and that time everything worked fine.
any ideas how to test if any communication can be done between the device & the host?
thanks!
-
- Rank 1
- Posts: 21
- Joined: Wed Dec 30, 2009 3:24 pm
Re: hid-data on tiny45
I managed to communicate with the device as well as sending and receiving bytes
The trick is to get rid of include "osccal.h" before you compile the hidtool.
And then add it again after you finish compiling
The trick is to get rid of include "osccal.h" before you compile the hidtool.
And then add it again after you finish compiling