本帖最后由 panxiaoyi 于 2021-5-4 01:03 编辑
#include "debug.h"
#include "Font0805.h"
#include "IIC.h"
#include "OLED.h"
unsigned int i;
int main(void)
{
// NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
// Delay_Init();
USART_Printf_Init(115200);
// printf("SystemClk:%d\r\n",SystemCoreClock);
// printf("This is printf example\r\n");
RCC->CTLR = 0x00000081; //使能内部HSI振荡器8MHz,时钟微调默认
RCC->CFGR0 = 0x00280002; //PLL=12倍频,默认使用1/2震荡器时钟,系统时钟使用PLL
RCC->CTLR |= 0x01000000; //使能PLL倍频,CPU时钟=8/2*12=48MHz
IIC_Init();
OLED_Init();
OLED_Clear();
OLED_Gotoxy(11,1);
OLED_String("CH32V103 -> SH1106");
OLED_Gotoxy(11,5);
OLED_String("21IC.COM PANXIAOYI");
while(1)
{
OLED_Gotoxy(52,3);
OLED_ShowU16(i);
i++;
}
}
请教一下大家:
上面这条 USART_Printf_Init(115200); 是系统生成的代码,我想删除它,如果删除,则编译出错。
或者删除后,把下面的相同类型的 IIC_Write 代码也随便删除12条以上,则编译通过
请问是为什么?
void OLED_Init(void)
{
OLED_Delay(65535);
IIC_Start();
IIC_WriteAddr(0x78);//总线OLED地址
IIC_Write(0x00);//准备写指令
IIC_Write(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
IIC_Write(0x81);//双字节指令,亮度
IIC_Write(0x05);//亮度 0-FF
IIC_Write(0xA1);//--Set SEG/Column Mapping 0xa0左右反置 0xa1正常
IIC_Write(0xC8);//Set COM/Row Scan Direction 0xc0上下反置 0xc8正常
IIC_Write(0xA8);//--set multiplex ratio(1 to 64)
IIC_Write(0x3f);//--1/64 duty
IIC_Write(0xD3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F)
IIC_Write(0x00);//-not offset
IIC_Write(0xd5);//--set display clock divide ratio/oscillator frequency
IIC_Write(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
IIC_Write(0xD9);//--set pre-charge period
IIC_Write(0xF1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
IIC_Write(0xDA);//--set com pins hardware configuration
IIC_Write(0x12);
IIC_Write(0xDB);//--set vcomh
IIC_Write(0x40);//Set VCOM Deselect Level
IIC_Write(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
IIC_Write(0x02);//
IIC_Write(0x8D);//--set Charge Pump enable/disable
IIC_Write(0x14);//--set(0x10) disable
IIC_Write(0xA4);//正常,全亮 (0xa4/0xa5)
IIC_Write(0xA6);// Disable Inverse Display On (0xa6/a7)
IIC_Write(0xC0);//180`
IIC_Write(0xA0);//180`
IIC_Write(0xC8);//0`
IIC_Write(0xA1);//0`
IIC_Write(0xA6);//正常A6,反显A7
IIC_Write(0xAF);//关闭AE,显示AF
IIC_Stop();
}
附件是可以正常运行的代码,我目的是想删除 USART_Printf_Init(115200); 这行代码
|