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.

[参考译文] CCS/MSP430G2553:SSD1306 OLED 连接

Guru**** 2502205 points
Other Parts Discussed in Thread: MSP430G2253

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/612318/ccs-msp430g2553-ssd1306-oled-interfacing

器件型号:MSP430G2553
主题中讨论的其他器件:MSP430G2253

工具/软件:Code Composer Studio

我有一个项目、 在该项目中、我尝试将 ssd1306 OLED 显示屏与4x4键盘连接在一起、它应在按下*时显示图像、在按下#时显示另一个图像、 如果 有人能指导我如何进行讨论,我就会很感激

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    #include 
    
    /*
    0xAE、//显示关闭
    0x81、//设置对比度控制寄存器
    0x7F、//对比度 Wert 127 ok
    
    0x20、//设置存储器地址模式
    0x01、//垂直地址模式
    
    0x21、//设置列地址
    0x00、//开始地址0
    0x7F、//结束地址127
    
    0x22、//设置页面地址
    0x00 //开始地址0
    0x07,//结束地址7
    
    0x40,//设置开始行地址0
    
    0xA0,//列地址映射到 SEG0
    
    0xA8,//设置比率
    0x3F,//最大
    
    值0xC0,//将 COM 输出扫描方向设置为正常模式
    
    0xD3,//设置显示偏移
    0x00,// 0
    
    0x8D,多路复用 //设置电荷泵设置
    0x14,//在
    
    0xDA 上,//设置 COM 引脚硬件配置
    0x12,//替代+禁用重映射
    
    0xD5,//设置显示时钟分频+频率
    0x80,//除以1和中等频率
    
    0xD9,//设置预充电预发布器
    0x22,//中等(复位值)
    
    0xDB, //设置 vcomh
    0x20,// 0.77 x Vcc
    
    0xA4,//输出跟随 RAM 内容
    
    0xAF //显示 on*/
    
    
    const unsigned char Init[]={0xAE,0x81,0x20,0x01,0x21,0x00,0x7,0x20
    
    
    
    
    ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20
    
    
    
    
    void printC (const unsigned char*数组、unsigned int length){
    
    UCB0CTL1 = UCSWRST;
    UCB0CTL0 = UCMODE_3 + UCMST + UCSYNC;// I2C 主模式
    UCB0CTL1 = UCSSEL_2 + UCSWRST;//使用 SMCLK、保持 SW 复位
    UCB0BR0 = 0x40; //< 100kHz
    UCB0I2CSA = 0x3C; //地址
    UCB0CTL1 &=~UCSWRST;
    IE2 |= UCB0TXIE;//启用 TX 就绪中断
    __DISABLE_INTERRUPT ();
    UCB0CTL1 |= UCTR + UCTXSTT;// I2C TX,启动条件
    
    
    __bis_register (LPM3_bits + GIE);UCB0+
    
    
    
    
    
    
    = UCB0bis_t = UCB0+= UCB0bis += UCTXCC_t;// UPM3+= UCB0+= UCB0BIS_R+寄存器= UCB0+= UCB0+= UCB0+= UCB0BIS_BIT_BIT_CLB = UCB0+
    _bis_SR_register (LPM3_bits + GIE);
    }
    
    UCB0CTL1 |= UCTXSTP;
    IE2 &=~UCB0TXIE;
    
    }
    
    void prints (void){
    UCB0CTL1 = UCSWRST;
    UCB0CTL0 = UCMODE_3 + UCMST + UCSYNC;// I2C 主模式
    UCB0CTL1 = UCSBREL_2 + UCSWRST
    ;使用0x40 SW /复位 //< 100kHz
    UCB0I2CSA = 0x3C; //地址
    UCB0CTL1 &=~UCSWRST;
    IE2 |= UCB0TXIE;//启用 TX 就绪中断
    __DISABLE_INTERRUPT ();
    UCB0CTL1 |= UCTR + UCTXSTT;// I2C TX,开始条件
    
    __bis_register (LPM3_bits + GIE);UCB0CTL
    
    
    
    
    + UCTL void + UCTL = UCTL void + UCTL (void);// I2C TX void + UCB0CCTRI + UCTL = UCTL = UCTL = UCTL = UCTL + UCTL void + UCTL = UCTL = UCTL void + UCTL void + UCTL = UCTL = UCTL = UCT
    
    
    
    
    
    
    
    
    WDTCTL = WDTPW + WDTHOLD;
    
    DCOCTL = CALDCO_8MHZ;//DCO 设置= 8MHz
    BCSCTL1 = CALBC1_8MHZ;//DCO 设置= 8MHz
    
    //为 I2C 配置引脚
    P1SEL |= BIT6 + BIT7; //引脚初始化
    P1SEL2 |= BIT6 + BIT7; //引脚初始化
    
    
    printC (Init、31);
    
    _delay_cycles (8000000);
    
    printC (Mod、1);
    
    /*
    prints();
    
    
    
    UCB0TXBUF = 0x00;
    _bis_SR_register (LPM3_bits + GIE);
    
    
    unsigned int i;
    对于(i = 500;i > 0;i--){
    printD (0xFF);
    printD (0x00);
    }
    Printe();*/
    
    while (1);
    
    }
    
    
    // USCI_B0数据 ISR
    #pragma vector = USCIAB0TX_vector
    __interrupt void USCIAB0TX_ISR (void){
    IFG2 &&=~UCB0TXIFG;
    __BIC_SR_REGISTER_ON_EXIT (LPM3_BITS); //唤醒主代码
    } 

    此代码在使用 I2C 的 MSP430G2253 + SSD1306上运行正常。 执行代码后、显示屏应完全盖住 (0xA5 ->所有像素打开)。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    非常感谢,我可以从这里构建一些东西:)