Forum breadcrumbs - You are here:ForumGeneral: Report BugsAttiny85 USI I2C
You need to log in to create posts and topics.

Attiny85 USI I2C

PreviousPage 5 of 5

Rev 2133 is working a lot better and I did some initial tests to talk to a SSD1306 Oled. Well, it's not working (at least there is no visible output) but the TWI protocol seems to be ok.

This is the start of the initialization sequence. There is a glitch on the SDA line at the end of the first command, but that may not be problematic. The sequence of commands is just like expected. I need to recheck if my code runs on real hardware. Is SSD1306 a good choice for testing? Is it known to work? Are there other parts that could be used for testing?

I tested a simple example with SSD1306 and it's working for me:

There are some other components using I2C, for example I2C RAM, I2C to Parallel, AIP31068 LCD, DS1306 RTC, DS1621 Temp. sensor, Microcontrllers with TWI, and even custom script components can use I2C.

EDIT: are you sure that the address is correct?

Well, the most important thing is that the Tiny85 works with the OLED, this gives it immense practical use, thank you very much, you are CHAMPIONS, CONGRATULATIONS.

Question: Would this also apply to the other useful Tiny, such as Tiny84?

Got it working. It was an error in the firmware.

arcachofo has reacted to this post.
arcachofo

Looks like there is still a minor issue in the USI code which disables the pwm output on PB1 timer1 is configure like this

  DDRB |= (1 << PB1); // PWM as output
  GTCCR |= (1 << PSR1);
  TCCR1 = 1 << PWM1A | 1 << COM1A1 | /* 1 << COM1A0 | */ 1 << CS12 | 1 << CS11 | 1 << CS10;
  TCNT1=0x00;
  OCR1A = 0xA0;
  OCR1C = 0xFF;

PB1 (OC1A) is the output the pwm signal, but it remains high all the time. After some debugging I found

USICR  =  (0<<USISIE)|(0<<USIOIE)|                  // Disable Interrupts.
          (1<<USIWM1)|(0<<USIWM0)|                  // Set USI in Two-wire mode.
          (1<<USICS1)|(0<<USICS0)|(1<<USICLK)|      // Software stobe as counter clock source
          (0<<USITC);

to be the reason. I suppose it manipulates PORTB in some way which turns the pwm signal off. I can still toggle PB1 but the pwm signal will only reappear if USICR isn't set.

Looks like there is still a minor issue in the USI code which disables the pwm output on PB1 timer1

Solved at Rev 2136.

Thanks. It's working!

arcachofo has reacted to this post.
arcachofo
PreviousPage 5 of 5