Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't compile on ATTiny84 #21

Open
gion86 opened this issue Oct 1, 2017 · 2 comments
Open

Doesn't compile on ATTiny84 #21

gion86 opened this issue Oct 1, 2017 · 2 comments

Comments

@gion86
Copy link

gion86 commented Oct 1, 2017

I have the same error as in issue #3.
Now I could try to use a different timer on the tiny84, timer1 should be ok??
The problem is that, from the datasheet, I see the prescaler can only be: 1, 8, 64, 256.... but no 32.
So is there anything else I have to change to make it work on the tiny84 with the prescaler at 64 for example??
Should be something similar to the work of @SRGDamia1 for AtMega32...

Thanks!

@SRGDamia1
Copy link

SRGDamia1 commented Oct 3, 2017

On the 32u4, I solved the missing timer 2 by picking another timer (4) with the right prescaler. It doesn't look like the ATtinyx4 has that option. I think with a different prescaler/timer speed you'd need to adjust the TICKS_PER_BIT and BITS_PER_TICK values for that speed (similar to the discussion in #19)

@gion86
Copy link
Author

gion86 commented Oct 4, 2017

Grazie Sara! ;)

I've made the changes to compile and run on the Tiny84 (I will eventually create a pull request):
TCCR1A = 0x00; // "normal" operation - Normal port operation, OC1A & OC1B disconnected
TCCR1B = 0x03; // 0b00000011 - Clock Select bits 11 & 10 on - prescaling source = CK/64

The timer is timer 1, and PCI_FLAG_REGISTER is GIFR (same as Tiny85).

Now that the timer is running at 8MHz/64 = 125kHz:

static const uint8_t TICKS_PER_BIT_9600 = 13; // 9600 baud bit width in units of 8us
static const uint8_t TICKS_PER_BIT_31250 = 4; // 31250 baud bit width in units of 8us
static const uint16_t BITS_PER_TICK_31250_Q10 = 256; // 31250 bps * 0.000008 s * 2^10 "multiplier"
static const uint16_t BITS_PER_TICK_38400_Q10 = 314; // 1s/(38400 bits) * (1 tick)/(8 us) * 2^10 "multiplier"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants