This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP-EXP430FR5994:通过 I2C PCF8574连接到 LCD

Guru**** 2387060 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1052579/msp-exp430fr5994-connect-to-lcd-via-i2c-pcf8574

器件型号:MSP-EXP430FR5994

您好!

遗憾的是、我在通过 I2C 控制 LCD 方面遇到了问题。 我无法连接到 LCD。 我将在 CCS 中使用以下 asm 代码: 

;-------------------------------------------------------------------------------
; Init
;-------------------------------------------------------------------------------

RESET       			mov.w   #__STACK_END,SP                     ; Initialize stackpointer
STOP_WDT	  			mov.w   #WDTPW|WDTHOLD,&WDTCTL              ; Stop watchdog timer

;-------------------------------------------------------------------------------
; GPIO Init
;-------------------------------------------------------------------------------

GPIO_INIT				bis.b	#BIT0+BIT1, &P7SEL0					; Set P7SEL0 = 1
						bic.b	#BIT0+BIT1, &P7SEL1					; Set P7SEL1 = 0

						bic.w	#LOCKLPM5, &PM5CTL0					; Disable the GPIO power-on default high-impedance mode to activate
   																	; previously configured port settings

;-------------------------------------------------------------------------------
; I2C Init
;-------------------------------------------------------------------------------

I2C_INIT				bis.b	#UCSWRST, &UCB2CTLW0 				; enable i2c config

 						bis.b	#UCSYNC+UCMODE_3+UCMST, &UCB2CTLW0	; synchronous-mode, i2c-mode, master-mode
						bis.b	#UCSSEL__SMCLK, &UCB2CTLW0			; transmitter, clock = SMCLK
						bis.b	#160, &UCB2BRW						; fSCL = SMCLK/160 = ~100kHz

						bic.b   #UCSWRST, &UCB2CTLW0 				; disable i2c config

;-------------------------------------------------------------------------------
; Slave Init
;-------------------------------------------------------------------------------
						
SLAVE_INIT				mov.b	#027h, R11							; address
						mov.b	#000h, R12							; register
						mov.b	#000h, R13							; data

WAIT_LOOP				bit.w	#UCBBUSY, &UCB2STATW
						jnz		WAIT_LOOP							; wait until bus is ready
						mov.w	R11, &UCB2I2CSA						; set slave address
						bis.b	#UCTR+UCTXSTT, &UCB2CTLW0			; generate start condition
						mov.b	R12, &UCB2TXBUF						; set slave register

						bit.b	#UCNACKIFG,	&UCB2STATW
						jnz		ERROR_NACK							; if nack received jump to error handling
						bit.b	#UCTXIFG0, &UCB2IFG
						jz		SLAVE_INIT							; else if ack received


						call	#MASTER_TRANSMIT

由于 UCB2IFG、它总是失败。 我从未达到 MASTER_init 的调用。 我已经尝试了所有地址。 错误的寄存器可能是问题、或者什么? 


此致、
Sascha