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.
Hi all ,
I need to write a code (assembly) to configure EEPROM registers of power manager IC (MAX 6889) using I2C.(MSP 430 as master and this IC as slave).
First I need to read the corresponding registers to know what is written on it and then configure it by myself.
just need the code below to be verified for the structure (slave address and actual configuration data doesnt matter). In this code only write is attempted .Request suggestions to 'read corresponding registers' too.
Code to Configure I2C port and to Establish Communication with Power Manager
#include <msp430xG46x.h>
;-------------------------------------------------------------------------------
RSEG CSTACK ; Define stack segment
;-------------------------------------------------------------------------------
RSEG CODE ; Assemble to Flash memory
;-------------------------------------------------------------------------------
RSEG INFO ; Assemble to INFORMATION MEMORY
;-----------------------------------------------------------------------------
RESET MOV.W #SFE(CSTACK),SP ; Initialize stack pointer
STOPWDT MOV.W WDTPW+WDTHOLD+WDTNMI+WDTTMSEL+WDTSSEL,&WDTCTL ; Stop Watch Dog Timer
START
MOV.W #TX_DATA0,R15 ;Address Of Tx_Data0 In R15
MOV.W #TX_DATA1,R14
MOV.B #02,R11
MOV.B #08,R10
SETUPSVS MOV.B #018H,&SVSCTL ;threshold voltage Vth = 1.9V
SETUPRTC MOV.B #30h,&RTCCTL ; real time clock in calendar mode
Bis.B #RTCBCD,&RTCCTL
SETUPP3 ; BIS.B #UCSWRST,&UCB0CTL1 ;keeping the USCIB0 in reset
Bis.B #06h,&P3SEL ; Assign I2C pins to USCI_B0
I2c BIS.B #UCSWRST,&UCB0CTL1 ;holding the usci port high
MOV.B #0Fh,&UCB0CTL0 ;synch,I2C,master mode
BIS.B #UCSSEL_2+UCSWRST,&UCB0CTL1 ; Use SMCLK, keep SW reset
MOV.B #11,&UCB0BR0 ; fSCL = SMCLK/11 = 95.3kHz
MOV.B #00,&UCB0BR1
POWER MANAGER
BIS.B #UCB0TXIE,&IE2 ; Enable TX interrupt
BIC.B #UCSWRST,&UCB0CTL1 ; Clear SW reset, resume operation
MOV.W #050h,&UCB0I2CSA ; Set slave address of Power Manager
TX BIS.B #UCTXSTT+UCTR,&UCB0CTL1 ;generate start condition in tx mode
EINT ; ; enable global interrupt
BIT.B #UCB0TXIFG,&IFG2 ; check if transmit interrupt flag is set
JNZ USCIAB0TX_ISR0 ;if set go to USCIAB0TX_ISR0
;...............................................................................
TX_DATA0
DB 04h ; address of register in max6889
DB 01H ;switch on max 6889
TX_DATA1
DB 09H ;port configuration registers from 09h to 0fh
DB 055H ; configuring in output in subsequent write mode
DB 055H
DB 055H
DB 055H
DB 055H
DB 055H
DB 055H
USCIAB0TX_ISR0
MOV.B @R15+,&UCB0TXBUF ; moving the data in TX_DATA0 to Tx buffer
DEC R11 ;for two data bytes
JNZ USCIAB0TX_ISR0
BIC.B #UCB0TXIFG,&IFG2 ;transmit interrupt flag is cleared
BIS.B #UCTXSTP,&UCB0CTL1 ;I2C stop condition
BIC.B #UCTXSTP,&UCB0CTL1 ;moving out of stop condition
BIS.B #UCTXSTT+UCTR,&UCB0CTL1 ;generate start condition in tx mode
USCIAB0TX_ISR1
MOV.B @R14+,&UCB0TXBUF ;transmitting the eight data bytes
DEC R10
JNZ USCIAB0TX_ISR1
BIC.B #UCB0TXIFG,&IFG2
BIS.B #UCTXSTP,&UCB0CTL1
EXIT_TX
BIC.B #UCB0TXIFG,&IFG2 ; transmit interrupt flag is cleared
BIS.B #UCTXSTP,&UCB0CTL1 ; I2C stop condition
RETI
;------------------------------------------------------------------------------
COMMON INTVEC ; Interrupt Vectors
;------------------------------------------------------------------------------
ORG USCIAB0TX_VECTOR ; USCI_B0 I2C Data Int Vector
DW USCIAB0TX_ISR0
ORG RESET_VECTOR ; MSP430 RESET Vector
DW RESET ;
END
**Attention** This is a public forum