MSP430单片机的软件IIC通信控制OLED的源程序如下:
- #include "msp430g2553.h"
- #include "LQ12864.h"
- void BCSplus_init(void)
- {
- BCSCTL2 = SELM_0 + DIVM_0 + DIVS_0;
- if (CALBC1_1MHZ != 0xFF) {
- DCOCTL = 0x00;
- DCOCTL = CALDCO_12MHZ;
- BCSCTL1 = CALBC1_12MHZ; /* Set DCO to 1MHz */
- }
- BCSCTL1 |= XT2OFF +DIVA_0;
- BCSCTL3 = XT2S_0 + LFXT1S_2 + XCAP_1;
- }
- void main(void)
- {
- WDTCTL = WDTPW + WDTHOLD;
- BCSplus_init();
- P2DIR |= BIT0 + BIT1;
- OLED_Init(); //OLED初始化
- while(1)
- {
- P2OUT &= ~BIT0;
- // OLED_Fill(0x01); //屏全亮
- OLED_ShowCHinese(20,0,3) ;
- OLED_ShowChar(0,0,'a',16);
- delay(2000);
- /* P2OUT |= BIT0;
- OLED_Fill(0x00); //屏全灭
- OLED_Fill(0xff); //屏全亮*/
- delay(2000);
- while(1);
- }
- }
复制代码
所有资料51hei提供下载:
430-oledV2.zip
(202.31 KB, 下载次数: 166)
|