Page 1 of 1

May be missing somthing ... 2 bugs in first 10 lines of code

Posted: Tue Oct 06, 2009 7:23 am
by rjburke377
I'm trying to get hid-data example to work on tiny2313. I only had a 16M crystal and have been fighting for a few days trying to get this to work. No joy yet.

Found a couple of very minor bugs ... I think:

Code: Select all

int main(void)
{
    uchar   i;

    wdt_enable(WDTO_1S);
    DBG1(0x00, 0, 0);       /* debug output: main starts */
    odDebugInit();
    ...
}


DBG1() statement used before odDebugInit().

Looking at odDebugInit()

Code: Select all

static inline void  odDebugInit(void)
{
    ODDBG_UCR |= (1<<ODDBG_TXEN);
    ODDBG_UBRR = F_CPU / (19200 * 16L) - 1;
}


DDR for Tx is not set as output. Tiny2313 is a few hundreds bytes short of memory to compile /w debug anyways. Would be nice to support double clock rate too.

Mailman just dropped by and left me a bunch of Tiny45's. Will try this part instead. 12Mhz crystals should arrive in the next day or so. This is a lot harder than expected.

/RJ

Re: May be missing somthing ... 2 bugs in first 10 lines of code

Posted: Wed Oct 07, 2009 1:05 am
by rjburke377
Wow. Got the Tiny45 to enumerate right away using internal PLL oscillator at 16.5MHz. What a pleasant experience compared to the Tiny2313 at 16MHz. I'll program the other 10 Tiny45 chips to see if they respond in the same way. Fingers crossed.

I got an AVRISP mkII to calibrate the Tiny45 internal oscillator should it be needed. I've seen questions about the process. It is described in avr053: calibration of the internal rc oscillator.

Will try the Tiny2313 again when the 12MHz crystals arrive. The 16MHz crystals didn't work at all but to be fair they've been in my electronics bin for 10 years. Still, they appeared to function correctly. Looking forward to having things work with the new 12MHz crystals. Fingers and toes crossed for extra luck. I hope this expression translates otherwise it will sound silly.

/RJ

Re: May be missing somthing ... 2 bugs in first 10 lines of code

Posted: Sat Oct 24, 2009 10:51 pm
by christian
rjburke377 wrote:DBG1() statement used before odDebugInit().


Thanks for this hint! It's indeed a bug!

Regarding the 16 MHz version: Have you checked with a simple non-USB program which blinks an LED that the clock rate is OK?

Re: May be missing somthing ... 2 bugs in first 10 lines of code

Posted: Wed Oct 28, 2009 4:55 am
by rjburke377
Yes, that exactly what I did to test the crystals.

Now that I have some experience with V-USB I also have more confidence using your software. It was probably a setup issue. I suspect I had the 1.5K on D+. :oops: The 2313 is useless for me anyways because of the limited available memory.

Thank you for response Christian.

/RJ