这是用XS128驱动OLED的程序。
------------------------------------CodeWarrior5.0/1Target:MC9S12XS128Crystal:16.000Mhzbusclock:16.000MHzpllclock:32.000MHz============================================使用说明:OLED电源使用5V。
----------------G电源地3.3V接5V电源,电源跟模块之间串接100欧姆电阻,并加3.3V钳位二极管D0PORTE_PE2单片机跟模块之间串接2k-3.3k电阻D1 PORTE_PE3单片机跟模块之间串接2k-3.3k电阻RSTPORTE_PE4单片机跟模块之间串接2k-3.3k电阻DCPORTE_PE5单片机跟模块之间串接2k-3.3k电阻CS已接地,不用接============================================如果用户使用的是5V单片机,请看用户手册,切勿烧毁模块!============================================*/#include"derivative.h"#include#include#include"OLED12864.h"//PLL初始化子程序BUSClock=16MvoidSetBusCLK_48M(void){CLKSEL=0X00;//disengagePLLtosystemPLLCTL_PLLON=1;//turnonPLLSYNR=0xc0|0x05;REFDV=0x80|0x01;POSTDIV=0x00;//pllclock=2*osc*(1+SYNR)/(1+REFDV)=96MHz;_asm(nop);//BUSCLOCK=48M_asm(nop);while(!(CRGFLG_LOCK==1));//whenpllissteady,thenuseit;CLKSEL_PLLSEL=1;//engagePLLtosystem;}voidDly_ms(intms){intii,jj;if(ms<1)ms=1;for(ii=0;ii<ms;ii++)for(jj=0;jj<1335;jj++);//16MHz--1ms//for(jj=0;jj<4006;jj++);//48MHz--1ms//for(jj=0;jj<5341;jj++);//64MHz--1ms}//============================MAIN()===========================/*********************主函数************************************/voidmain(void){bytei=0;SetBusCLK_48M();DDRB=0XFF;DDRE=0XFF;PORTB=0XFF;LCD_Init();DisableInterrupts;for(;;){//LCD_Fill(0xff);//Dly_ms(100);//LCD_Fill(0x00);//Dly_ms(2000);//LCD_CLS();//LCD_Print(12,0,"广州Beyond科技");//LCD_Print(15,2,"飞思卡尔智能车");//LCD_Print(43,4,"专营店");//LCD_Print(15,6,"智能车首选液晶");//LCD_P8x16Str(48,4,"OLED");//LCD_P6x8Str(16,6,"b
2023/10/17 14:34:33
255KB
OED例程
1