MSP430 f5529 硬件IIC OLED 单片机

https://blog.csdn.net/x1131230123/article/details/108686377
MSP430 f5529 基本和MSP430 G2553的IIC模块一样,寄存器名字有点不同。
地址依旧是0X3C.

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
    UCB0BR0 = 12;                             // fSCL = SMCLK/12 = ~100kHz
    UCB0BR1 = 0;
    UCB0I2CSA = ADDRESS;                         // Slave Address is ADDRESS
    UCB0CTL1 &= ~UCSWRST;                    // Clear SW reset, resume operation

    while ((UCB0STAT & UCBUSY) || UCB0CTL1 & UCTXSTP)
        ;       // 确保总线空闲
#include <msp430.h>
#include "oled.h"

#include "bmp.h"

//                  MSP430G2xx3
//                 -----------------
//OLED  |   |   --|RST          XOUT|-
//---   |   |     |                 |
//SDA|<-|---+---->|P3.0/UCB0SDA     |
//   |  |         |                 |
//   |  |         |                 |
//SCL|<-+---------|P3.1/UCB0SCL     |
//   |            |                 |

int main(void)
{
    
    

    WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

    OLED_Init();
    delay_ms(100);

    OLED_DrawBMP(0,0,128,64,BMP1);
    delay_ms(2000);
    OLED_Fill(0X00);
    show(10,0);
    show(64,32);

    while (1)
    {
    
    


    }
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/x1131230123/article/details/108692029