ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
28 ноября
376080 Топик полностью
dxwak (17.12.2012 12:52, просмотров: 476) ответил MBedder на Кто-нибудь поднимал графику на grayscale PMOLED 256x64 с контроллером SSD1322? Никак не пойму его транслятора RAM-to-pixels - пишу вроде в правильные адреса, а вижу совсем не там, где должно быть
У меня работал, прилагаю файл с исходниками:  #include "UG5664.h" #include "Timer3.h" SSD1322 UG5664; void SSD1322::Write_Command(INT8U Data) { CD_0_UG5664; CE_0_UG5664; WR_0_UG5664; FIO2CLR=0x1FE; FIO2SET=((INT16U)Data<<1)&0x000001FE; WR_1_UG5664; CE_1_UG5664; CD_1_UG5664; } void SSD1322::Write_Data(INT8U Data) { CE_0_UG5664; WR_0_UG5664; FIO2CLR=0x1FE; FIO2SET=((INT16U)Data<<1)&0x000001FE; WR_1_UG5664; CE_1_UG5664; } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Instruction Setting //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void SSD1322::Set_Column_Address(unsigned char a, unsigned char b) { Write_Command(0x15); // Set Column Address Write_Data(a); // Default => 0x00 Write_Data(b); // Default => 0x77 } void SSD1322::Set_Row_Address(unsigned char a, unsigned char b) { Write_Command(0x75); // Set Row Address Write_Data(a); // Default => 0x00 Write_Data(b); // Default => 0x7F } void SSD1322::Set_Write_RAM() { Write_Command(0x5C); // Enable MCU to Write into RAM } void SSD1322::Set_Read_RAM() { Write_Command(0x5D); // Enable MCU to Read from RAM } void SSD1322::Set_Remap_Format(unsigned char d) { Write_Command(0xA0); // Set Re-Map / Dual COM Line Mode Write_Data(d); // Default => 0x40 // Horizontal Address Increment // Column Address 0 Mapped to SEG0 // Disable Nibble Remap // Scan from COM0 to COM[N-1] // Disable COM Split Odd Even Write_Data(0x11); // Default => 0x01 (Disable Dual COM Mode) } void SSD1322::Set_Start_Line(unsigned char d) { Write_Command(0xA1); // Set Vertical Scroll by RAM Write_Data(d); // Default => 0x00 } void SSD1322::Set_Display_Offset(unsigned char d) { Write_Command(0xA2); // Set Vertical Scroll by Row Write_Data(d); // Default => 0x00 } void SSD1322::Set_Display_Mode(unsigned char d) { Write_Command(0xA4|d); // Set Display Mode // Default => 0xA4 // 0xA4 (0x00) => Entire Display Off, All Pixels Turn Off // 0xA5 (0x01) => Entire Display On, All Pixels Turn On at GS Level 15 // 0xA6 (0x02) => Normal Display // 0xA7 (0x03) => Inverse Display } void SSD1322::Set_Partial_Display(unsigned char a, unsigned char b, unsigned char c) { Write_Command(0xA8|a); // Default => 0x8F // Select Internal Booster at Display On if(a == 0x00) { Write_Data(b); Write_Data(c); } } void SSD1322::Set_Function_Selection(unsigned char d) { Write_Command(0xAB); // Function Selection Write_Data(d); // Default => 0x01 // Enable Internal VDD Regulator } void SSD1322::Set_Display_On_Off(unsigned char d) { Write_Command(0xAE|d); // Set Display On/Off // Default => 0xAE // 0xAE (0x00) => Display Off (Sleep Mode On) // 0xAF (0x01) => Display On (Sleep Mode Off) } void SSD1322::Set_Phase_Length(unsigned char d) { Write_Command(0xB1); // Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment Write_Data(d); // Default => 0x74 (7 Display Clocks [Phase 2] / 9 Display Clocks [Phase 1]) // D[3:0] => Phase 1 Period in 5~31 Display Clocks // D[7:4] => Phase 2 Period in 3~15 Display Clocks } void SSD1322::Set_Display_Clock(unsigned char d) { Write_Command(0xB3); // Set Display Clock Divider / Oscillator Frequency Write_Data(d); // Default => 0xD0 // A[3:0] => Display Clock Divider // A[7:4] => Oscillator Frequency } void SSD1322::Set_Display_Enhancement_A(unsigned char a, unsigned char b) { Write_Command(0xB4); // Display Enhancement Write_Data(0xA0|a); // Default => 0xA2 // 0xA0 (0x00) => Enable External VSL // 0xA2 (0x02) => Enable Internal VSL (Kept VSL Pin N.C.) Write_Data(0x05|b); // Default => 0xB5 // 0xB5 (0xB0) => Normal // 0xFD (0xF8) => Enhance Low Gray Scale Display Quality } void SSD1322::Set_GPIO(unsigned char d) { Write_Command(0xB5); // General Purpose IO Write_Data(d); // Default => 0x0A (GPIO Pins output Low Level.) } void SSD1322::Set_Precharge_Period(unsigned char d) { Write_Command(0xB6); // Set Second Pre-Charge Period Write_Data(d); // Default => 0x08 (8 Display Clocks) } void SSD1322::Set_Precharge_Voltage(unsigned char d) { Write_Command(0xBB); // Set Pre-Charge Voltage Level Write_Data(d); // Default => 0x17 (0.50*VCC) } void SSD1322::Set_VCOMH(unsigned char d) { Write_Command(0xBE); // Set COM Deselect Voltage Level Write_Data(d); // Default => 0x04 (0.80*VCC) } void SSD1322::Set_Contrast_Current(unsigned char d) { Write_Command(0xC1); // Set Contrast Current Write_Data(d); // Default => 0x7F } void SSD1322::Set_Master_Current(unsigned char d) { Write_Command(0xC7); // Master Contrast Current Control Write_Data(d); // Default => 0x0f (Maximum) } void SSD1322::Set_Multiplex_Ratio(unsigned char d) { Write_Command(0xCA); // Set Multiplex Ratio Write_Data(d); // Default => 0x7F (1/128 Duty) } void SSD1322::Set_Display_Enhancement_B(unsigned char d) { Write_Command(0xD1); // Display Enhancement Write_Data(0x82|d); // Default => 0xA2 // 0x82 (0x00) => Reserved // 0xA2 (0x20) => Normal Write_Data(0x20); } void SSD1322::Set_Command_Lock(unsigned char d) { Write_Command(0xFD); // Set Command Lock Write_Data(0x12|d); // Default => 0x12 // 0x12 => Driver IC interface is unlocked from entering command. // 0x16 => All Commands are locked except 0xFD. } void SSD1322::Fill_RAM(unsigned char Data) { unsigned char i,j; Set_Column_Address(0x00,0x77); Set_Row_Address(0x00,0x7F); Set_Write_RAM(); for(i=0;i<128;i++) { for(j=0;j<120;j++) { Write_Data(Data); Write_Data(Data); } } } void SSD1322::Set_Gray_Scale_Table() { Write_Command(0xB8); // Set Gray Scale Table Write_Data(0x00); // Gray Scale Level 1 Write_Data(0x01); // Gray Scale Level 2 Write_Data(0x03); // Gray Scale Level 3 Write_Data(0x06); // Gray Scale Level 4 Write_Data(0x0A); // Gray Scale Level 5 Write_Data(0x10); // Gray Scale Level 6 Write_Data(0x1A); // Gray Scale Level 7 Write_Data(0x28); // Gray Scale Level 8 Write_Data(0x37); // Gray Scale Level 9 Write_Data(0x47); // Gray Scale Level 10 Write_Data(0x58); // Gray Scale Level 11 Write_Data(0x6A); // Gray Scale Level 12 Write_Data(0x7F); // Gray Scale Level 13 Write_Data(0x96); // Gray Scale Level 14 Write_Data(0xB4); // Gray Scale Level 15 Write_Command(0x00); // Enable Gray Scale Table } void Enable_LCD_VDDU() { FIO2DIR|=BIT13; //Подхват питания FIO2SET=BIT13; //Подхват питания } void Disable_LCD_VDDU() { FIO2DIR|=BIT13; //Подхват питания FIO2CLR=BIT13; //Подхват питания } void SSD1322::LCD_Init_On() { Init_Outputs_UG5664; Configure_Output_UG5664; WR_1_UG5664; RD_1_UG5664; CE_1_UG5664; CD_1_UG5664; RESET_0_UG5664; T3DelayMS(40); RESET_1_UG5664; Set_Command_Lock(0x12); // Unlock Basic Commands (0x12/0x16) Set_Display_On_Off(0x00); // Display Off (0x00/0x01) Set_Display_Clock(0x91); // Set Clock as 80 Frames/Sec Set_Multiplex_Ratio(0x3F); // 1/64 Duty (0x0F~0x3F) Set_Display_Offset(0x00); // Shift Mapping RAM Counter (0x00~0x3F) Set_Start_Line(0x00); // Set Mapping RAM Display Start Line (0x00~0x7F) Set_Remap_Format(0x14); // Set Horizontal Address Increment // Column Address 0 Mapped to SEG0 // Disable Nibble Remap // Scan from COM[N-1] to COM0 // Disable COM Split Odd Even // Enable Dual COM Line Mode Set_GPIO(0x00); // Disable GPIO Pins Input Set_Function_Selection(0x01); // Enable Internal VDD Regulator Set_Display_Enhancement_A(0xA0,0xFD); // Enable External VSL // Set Low Gray Scale Enhancement Set_Contrast_Current(0xDF); // Set Segment Output Current Set_Master_Current(Brightness); // Set Scale Factor of Segment Output Current Control Set_Gray_Scale_Table(); // Set Pulse Width for Gray Scale Table Set_Phase_Length(0xE8); // Set Phase 1 as 17 Clocks & Phase 2 as 14 Clocks Set_Display_Enhancement_B(0x20); // Enhance Driving Scheme Capability (0x00/0x20) Set_Precharge_Voltage(0x1F); // Set Pre-Charge Voltage Level as 0.60*VCC Set_Precharge_Period(0x08); // Set Second Pre-Charge Period as 8 Clocks Set_VCOMH(0x07); // Set Common Pins Deselect Voltage Level as 0.86*VCC Set_Display_Mode(0x02); // Normal Display Mode (0x00/0x01/0x02/0x03) Set_Partial_Display(0x01,0x00,0x00); // Disable Partial Display Fill_RAM(0x00); // Clear Screen 0x00.. //Здесь подаю питание 15 В на светодиоды Power up Vcc Enable_LCD_VDDU(); //Пауза 100 мс T3DelayMS(100); Set_Display_On_Off(0x01); // Display On (0x00/0x01) } void SSD1322::LCD_Init_Off() { Fill_RAM(0x00); // Clear Screen Set_Display_On_Off(0x00); // Display Off (0x00/0x01) //Power down Vcc Disable_LCD_VDDU(); //Пауза 100 мс T3DelayMS(100); RESET_0_UG5664; } void SSD1322::refresh_all_screen() { INT8U i,j; //Заполняю 'экран Set_Column_Address(0x00,0x77); Set_Row_Address(0x00,0x7F); Set_Write_RAM(); for(i=0;i<64;i++) { for(j=0;j<60;j++) Write_Data(0x00); for(j=0;j<120;j++) { Write_Data(videobuffer[i*120+j]); } for(j=0;j<60;j++) Write_Data(0x00); } } void SSD1322::Write_To_Videobuffer(INT16U adress,INT8U Byte) { if(adress<BYTES_PER_DISPLAY_UG5664) videobuffer[adress]=Byte; } INT8U SSD1322::Read_From_Videobuffer(INT16U adress) { return videobuffer[adress]; }