Jump to content

Проблема с подключением OLED 128x32 дисплея к AVR по I2C


Recommended Posts

Всем здрасти! Пытаюсь подружить драйвер дисплея SSD1306 и ATMEGA328p с использованием i2c.  По даташиту после каждого байта данных или команды, SSD1306 должен генерировать бит подтверждения, но после отправки первого же пакета с командой ни "Acknowledge" ни "Not Acknowledge" бита не получаю, симуляция будто зависает.  Подскажите пожалуйста может я что не так сделал? Может проблема симуляции?


				.include			"m328PBdef.inc"

				.def				buff		= r16
				.def				message	= r17
				.def				iter		= r18

				.equ				adressW = 0b01111000


				.org				0x0000
				jmp				restart

				.org				0x001A
				jmp				tim1_ovf_isr

				.org				0x0030
				jmp				twi_isr

restart:		ldi				buff,   high(RAMEND)
				out				SPH,    buff
				ldi				buff,   low(RAMEND)
				out				SPL,    buff
;				 twi init
				ldi				buff,   0b1100
				sts				TWBR0,  buff

				ldi				buff,   0b0
				sts				TWSR0,  buff
;				 timer\counter init
				ldi				buff,   0b100
				sts				TCCR1B, buff

				ldi				buff,   0b1
				sts				TIMSK1, buff
;				global interrupt enable
;				main routine

				jmp				main

;				timer 1 - 16bit overflow isr

tim1_ovf_isr:	ldi				buff,   0b10100101
				sts				TWCR0,  buff

				ldi				buff, 0b0
				sts				TCCR1B, buff

				ldi				buff,   0b0
				sts				TIMSK1, buff

;				twi isr
twi_isr:		lds				buff, TWSR0
				andi				buff, 0b11111000

				cpi				buff, 0x08
				breq				twi_start

				cpi				buff, 0x18
				breq				twi_slaw_ack

				cpi				buff, 0x28
				breq				twi_data_ack
twi_start:		ldi				buff, adressW
				sts				TWDR0, buff

				ldi				buff, 0b10000101
				sts				TWCR0, buff

twi_slaw_ack:	ldi				buff, 0b10000000
				sts				TWDR0, buff

				ldi				buff, 0b10000101
				sts				TWCR0, buff

twi_data_ack:	ldi				buff, 0xA5
				sts				TWDR0, buff

				ldi				buff, 0b10000101
				sts				TWCR0, buff



SSD1306-Revision 1.5.pdf

Edited by Deerael
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...