Skip to main content
fixed clear overflow flag
Source Link

Trying to shift out from ATtiny85 to a shift register using the USI in SPI mode. I have Timer 0 running as slowly as possible (checked it was running by temporarily changing it to toggle a pin with an LED attached.) I have LEDs hooked up to USCK and DO so by rights I should be able to see them blinking as it sends.

What else do I need to do in order to get it shifting out in sync with Timer 0? All the examples I've looked at so far strobe the USI clock manually.

#include <avr/io.h>

int main(void){
    DDRB = (1 << DDB2) | (1 << DDB1); // USCK & DO Output
    DDRB &= ~(1 << DDB0); // DI Input
    PORTB |= (1 << DDB0); // Pullup Resistor for DI

    TCCR0A = (1 << WGM01); // Timer 0 in CTC Mode
    OCR0A = 0xFF; // Timer 0 Compare A
    TCCR0B = (1 << CS02) | (1 << CS00); // Prescaler / 1024

    USICR = (1 << USIWM0); // USI 3 Wire Mode
    USICR |= (1 << USICS0); // Timer 0 for USI 4-bit Clock Source

    USIDR = 0x7F; // Why you no go? :c

    USISR |= 0x08; // Set Counter to 8
    USISR &== ~(1 << USIOIF); // Clear Counter Overflow

    while(1);
    return 0;
}

Trying to shift out from ATtiny85 to a shift register using the USI in SPI mode. I have Timer 0 running as slowly as possible (checked it was running by temporarily changing it to toggle a pin with an LED attached.) I have LEDs hooked up to USCK and DO so by rights I should be able to see them blinking as it sends.

What else do I need to do in order to get it shifting out in sync with Timer 0? All the examples I've looked at so far strobe the USI clock manually.

#include <avr/io.h>

int main(void){
    DDRB = (1 << DDB2) | (1 << DDB1); // USCK & DO Output
    DDRB &= ~(1 << DDB0); // DI Input
    PORTB |= (1 << DDB0); // Pullup Resistor for DI

    TCCR0A = (1 << WGM01); // Timer 0 in CTC Mode
    OCR0A = 0xFF; // Timer 0 Compare A
    TCCR0B = (1 << CS02) | (1 << CS00); // Prescaler / 1024

    USICR = (1 << USIWM0); // USI 3 Wire Mode
    USICR |= (1 << USICS0); // Timer 0 for USI 4-bit Clock Source

    USIDR = 0x7F; // Why you no go? :c

    USISR |= 0x08; // Set Counter to 8
    USISR &= ~(1 << USIOIF); // Clear Counter Overflow

    while(1);
    return 0;
}

Trying to shift out from ATtiny85 to a shift register using the USI in SPI mode. I have Timer 0 running as slowly as possible (checked it was running by temporarily changing it to toggle a pin with an LED attached.) I have LEDs hooked up to USCK and DO so by rights I should be able to see them blinking as it sends.

What else do I need to do in order to get it shifting out in sync with Timer 0? All the examples I've looked at so far strobe the USI clock manually.

#include <avr/io.h>

int main(void){
    DDRB = (1 << DDB2) | (1 << DDB1); // USCK & DO Output
    DDRB &= ~(1 << DDB0); // DI Input
    PORTB |= (1 << DDB0); // Pullup Resistor for DI

    TCCR0A = (1 << WGM01); // Timer 0 in CTC Mode
    OCR0A = 0xFF; // Timer 0 Compare A
    TCCR0B = (1 << CS02) | (1 << CS00); // Prescaler / 1024

    USICR = (1 << USIWM0); // USI 3 Wire Mode
    USICR |= (1 << USICS0); // Timer 0 for USI 4-bit Clock Source

    USIDR = 0x7F; // Why you no go? :c

    USISR |= 0x08; // Set Counter to 8
    USISR = (1 << USIOIF); // Clear Counter Overflow

    while(1);
    return 0;
}
included counter set and overflow clear
Source Link

Trying to shift out from ATtiny85 to a shift register using the USI in SPI mode. I have Timer 0 running as slowly as possible (checked it was running by temporarily changing it to toggle a pin with an LED attached.) I have LEDs hooked up to USCK and DO so by rights I should be able to see them blinking as it sends.

What else do I need to do in order to get it shifting out in sync with Timer 0? All the examples I've looked at so far strobe the USI clock manually.

#include <avr/io.h>

int main(void){
    DDRB = (1 << DDB2) | (1 << DDB1); // USCK & DO Output
    DDRB &= ~(1 << DDB0); // DI Input
    PORTB |= (1 << DDB0); // Pullup Resistor for DI

    TCCR0A = (1 << WGM01); // Timer 0 in CTC Mode
    OCR0A = 0xFF; // Timer 0 Compare A
    TCCR0B = (1 << CS02) | (1 << CS00); // Prescaler / 1024

    USICR = (1 << USIWM0); // USI 3 Wire Mode
    USICR |= (1 << USICS0); // Timer 0 for USI 4-bit Clock Source

    USIDR = 0x7F; // Why you no go? :c

    USISR |= 0x08; // Set Counter to 8
    USISR &= ~(1 << USIOIF); // Clear Counter Overflow

    while(1);
    return 0;
}

Trying to shift out from ATtiny85 to a shift register using the USI in SPI mode. I have Timer 0 running as slowly as possible (checked it was running by temporarily changing it to toggle a pin with an LED attached.) I have LEDs hooked up to USCK and DO so by rights I should be able to see them blinking as it sends.

What else do I need to do in order to get it shifting out in sync with Timer 0? All the examples I've looked at so far strobe the USI clock manually.

#include <avr/io.h>

int main(void){
    DDRB = (1 << DDB2) | (1 << DDB1); // USCK & DO Output
    DDRB &= ~(1 << DDB0); // DI Input
    PORTB |= (1 << DDB0); // Pullup Resistor for DI

    TCCR0A = (1 << WGM01); // Timer 0 in CTC Mode
    OCR0A = 0xFF; // Timer 0 Compare A
    TCCR0B = (1 << CS02) | (1 << CS00); // Prescaler / 1024

    USICR = (1 << USIWM0); // USI 3 Wire Mode
    USICR |= (1 << USICS0); // Timer 0 for USI 4-bit Clock Source

    USIDR = 0x7F; // Why you no go? :c

    while(1);
    return 0;
}

Trying to shift out from ATtiny85 to a shift register using the USI in SPI mode. I have Timer 0 running as slowly as possible (checked it was running by temporarily changing it to toggle a pin with an LED attached.) I have LEDs hooked up to USCK and DO so by rights I should be able to see them blinking as it sends.

What else do I need to do in order to get it shifting out in sync with Timer 0? All the examples I've looked at so far strobe the USI clock manually.

#include <avr/io.h>

int main(void){
    DDRB = (1 << DDB2) | (1 << DDB1); // USCK & DO Output
    DDRB &= ~(1 << DDB0); // DI Input
    PORTB |= (1 << DDB0); // Pullup Resistor for DI

    TCCR0A = (1 << WGM01); // Timer 0 in CTC Mode
    OCR0A = 0xFF; // Timer 0 Compare A
    TCCR0B = (1 << CS02) | (1 << CS00); // Prescaler / 1024

    USICR = (1 << USIWM0); // USI 3 Wire Mode
    USICR |= (1 << USICS0); // Timer 0 for USI 4-bit Clock Source

    USIDR = 0x7F; // Why you no go? :c

    USISR |= 0x08; // Set Counter to 8
    USISR &= ~(1 << USIOIF); // Clear Counter Overflow

    while(1);
    return 0;
}
Source Link

ATtiny85 SPI with Timer 0

Trying to shift out from ATtiny85 to a shift register using the USI in SPI mode. I have Timer 0 running as slowly as possible (checked it was running by temporarily changing it to toggle a pin with an LED attached.) I have LEDs hooked up to USCK and DO so by rights I should be able to see them blinking as it sends.

What else do I need to do in order to get it shifting out in sync with Timer 0? All the examples I've looked at so far strobe the USI clock manually.

#include <avr/io.h>

int main(void){
    DDRB = (1 << DDB2) | (1 << DDB1); // USCK & DO Output
    DDRB &= ~(1 << DDB0); // DI Input
    PORTB |= (1 << DDB0); // Pullup Resistor for DI

    TCCR0A = (1 << WGM01); // Timer 0 in CTC Mode
    OCR0A = 0xFF; // Timer 0 Compare A
    TCCR0B = (1 << CS02) | (1 << CS00); // Prescaler / 1024

    USICR = (1 << USIWM0); // USI 3 Wire Mode
    USICR |= (1 << USICS0); // Timer 0 for USI 4-bit Clock Source

    USIDR = 0x7F; // Why you no go? :c

    while(1);
    return 0;
}