[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] TINY13 PWM behavior stumps me.
From: |
Jim Brain |
Subject: |
[avr-gcc-list] TINY13 PWM behavior stumps me. |
Date: |
Fri, 13 Jun 2014 00:31:39 -0500 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
I have a chunk of code that operates fine on larger AVR8s, but does not
seem to operate on the T13. Just wondering if it's me (could be, this
is the first time I have used such a small AVR8), or the uC...
A snippet:
static volatile uint8_t i = 0;
int main(void) {
DDRB = _BV(PB0) | _BV(PB1);
TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
TCCR0B = _BV(CS00);
while (1) {
while(!(TIFR0 & _BV(OCF0A))) ;
TIFR0 |= _BV(OCF0A);
if(i == 2) {
i = 0;
}
OCR0A = 192;
else
OCR0A = 64;
i++;
}
When I run this on a larger AVR8, I get 192/64 split on the output, but
the T13 just shows the first value on the OCR0A output (192, in this case).
I changed the loop to be:
while (1) {
for(i = 0; i < 2;i++) {
while(!(TIFR0 & _BV(OCF0A))) ;
TIFR0 |= _BV(OCF0A);
if(!i)
PWM1_OCR = 192;
else
PWM1_OCR = 64;
}
}
And that shows random values (64 or 192, but in random arrangements, not
alternating...)
Obviously, this code is non optimal (my original code was an ISR), but I
thought I'd try to simplify to see if I could figure out the issue.
JIm
-- Jim Brain address@hidden www.jbrain.com
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-gcc-list] TINY13 PWM behavior stumps me.,
Jim Brain <=