Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: RE: rx8025 RTC with MSP430F5XXX using I2C

$
0
0
Hi Ryan, I have modified the source code as below: void main( void ) { struct rtc_time tmp, gettime; P3SEL |= 0x03; // Assign I2C pins to USCI_B0 UCB0CTL1 |= UCSWRST; // Enable SW reset UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset UCB0BR0 = 12; // fSCL = SMCLK/12 = ~100kHz UCB0BR1 = 0; UCB0I2CSA = 0x32; // Slave Address is 32h UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation tmp.tm_year = 2016; tmp.tm_mon = 1; tmp.tm_mday= 1; tmp.tm_hour = 0; tmp.tm_min = 0; tmp.tm_sec = 0; rtc_set(&tmp); while(1) { rtc_get(&gettime); __delay_cycles(500000); __delay_cycles(500000); } } int rtc_set (struct rtc_time *tmp) { rtc_write (RTC_YR_REG_ADDR, bin2bcd (tmp->tm_year % 100)); rtc_write (RTC_MON_REG_ADDR, bin2bcd (tmp->tm_mon)); rtc_write (RTC_DAY_REG_ADDR, bin2bcd (tmp->tm_wday)); rtc_write (RTC_DATE_REG_ADDR, bin2bcd (tmp->tm_mday)); rtc_write (RTC_HR_REG_ADDR, bin2bcd (tmp->tm_hour)); rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min)); rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec)); rtc_write (RTC_CTL1_REG_ADDR, RTC_CTL1_BIT_2412); return 0; } static void rtc_write (uint8_t reg, uint8_t val) { uint8_t buf[2]; buf[0] = reg Receive byte with NAK *receiveBufferPointer++ = USCI_B_I2C_masterMultiByteReceiveFinish( USCI_B0_BASE ); }else { //Keep receiving one byte at a time *receiveBufferPointer++ = USCI_B_I2C_masterMultiByteReceiveNext( USCI_B0_BASE ); } }else { //Receive last byte *receiveBufferPointer = USCI_B_I2C_masterMultiByteReceiveNext( USCI_B0_BASE ); } break; } default: break; } } I am not able to receive any transmit interrupt and code hang up at //Delay until transmission completes while (USCI_B_I2C_isBusBusy(USCI_B0_BASE)) ; One more thing i am using Slave address as 0x32 but in the RX8025 datasheet mentioned 0x64 & 0x65 slave address for read & write operation. I tried with 0x64h slave address also but results is same. Thanks & regards, John

Viewing all articles
Browse latest Browse all 62309

Trending Articles