Mi OLED 128x64 0.96 pulgadas (con el controlador SSD1306) no funciona.

0

Estoy trabajando para usar este OLED pero no sé ¿¡por qué no funciona !? El esquema del adaptador es este:

yesteesunproyectoensambladoeneltablero:

cuandorevisolospinesdeSPIdelmicrocontrolador(porLogicAnalyzer-saleae),veoestos:

ymiscódigossonesto:

/*****************************************************Project:OLEDDate:03/14/2014Author:RohChiptype:ATmega32AProgramtype:ApplicationAVRCoreClockfrequency:16.000000MHzMemorymodel:SmallExternalRAMsize:0DataStacksize:512*****************************************************/#include<mega32a.h>#include<delay.h>//SPIfunctions#include<spi.h>#defineBrightness0xCF#defineDCPORTA.0#defineRSTPORTA.1//DeclareyourglobalvariablesherevoidOLED_Init_I();voidFill_RAM(unsignedcharData);voidmain(void){//PortAinitialization//Func7=InFunc6=InFunc5=InFunc4=InFunc3=InFunc2=OutFunc1=OutFunc0=Out//State7=TState6=TState5=TState4=TState3=TState2=0State1=0State0=0PORTA=0x00;DDRA=0x07;//PortBinitialization//Func7=OutFunc6=OutFunc5=OutFunc4=OutFunc3=InFunc2=InFunc1=InFunc0=In//State7=0State6=0State5=0State4=0State3=TState2=TState1=TState0=TPORTB=0x00;DDRB=0xF0;PORTC=0x00;DDRC=0x00;PORTD=0x00;DDRD=0x00;//SPIinitialization//SPIType:Master//SPIClockRate:4000.000kHz//SPIClockPhase:CycleStart//SPIClockPolarity:Low//SPIDataOrder:MSBFirstSPCR=0x50;SPSR=0x00;OLED_Init_I();while(1){Fill_RAM(0xFF);delay_ms(1000);Fill_RAM(0x00);delay_ms(1000);//Placeyourcodehere}}voidspi_transfer_nr(unsignedchardata){DC=0;SPDR=data;while(!(SPSR&(1<<SPIF)));}voidspi_transfer_nr1(unsignedchardata){DC=1;SPDR=data;while(!(SPSR&(1<<SPIF)));}voidSet_Display_On_Off(unsignedchard){spi_transfer_nr(0xAE|d);//SetDisplayOn/Off//Default=>0xAE//0xAE(0x00)=>DisplayOff//0xAF(0x01)=>DisplayOn}voidSet_Display_Clock(unsignedchard){spi_transfer_nr(0xD5);//SetDisplayClockDivideRatio/OscillatorFrequencyspi_transfer_nr(d);//Default=>0x80//D[3:0]=>DisplayClockDivider//D[7:4]=>OscillatorFrequency}voidSet_Multiplex_Ratio(unsignedchard){spi_transfer_nr(0xA8);//SetMultiplexRatiospi_transfer_nr(d);//Default=>0x3F(1/64Duty)}voidSet_Display_Offset(unsignedchard){spi_transfer_nr(0xD3);//SetDisplayOffsetspi_transfer_nr(d);//Default=>0x00}voidSet_Start_Line(unsignedchard){spi_transfer_nr(0x40|d);//SetDisplayStartLine//Default=>0x40(0x00)}voidSet_Charge_Pump(unsignedchard){spi_transfer_nr(0x8D);//SetChargePumpspi_transfer_nr(0x10|d);//Default=>0x10//0x10(0x00)=>DisableChargePump//0x14(0x04)=>EnableChargePump}voidSet_Addressing_Mode(unsignedchard){spi_transfer_nr(0x20);//SetMemoryAddressingModespi_transfer_nr(d);//Default=>0x02//0x00=>HorizontalAddressingMode//0x01=>VerticalAddressingMode//0x02=>PageAddressingMode}voidSet_Segment_Remap(unsignedchard){spi_transfer_nr(0xA0|d);//SetSegmentRe-Map//Default=>0xA0//0xA0(0x00)=>ColumnAddress0MappedtoSEG0//0xA1(0x01)=>ColumnAddress0MappedtoSEG127}voidSet_Common_Remap(unsignedchard){spi_transfer_nr(0xC0|d);//SetCOMOutputScanDirection//Default=>0xC0//0xC0(0x00)=>ScanfromCOM0to63//0xC8(0x08)=>ScanfromCOM63to0}voidSet_Common_Config(unsignedchard){spi_transfer_nr(0xDA);//SetCOMPinsHardwareConfigurationspi_transfer_nr(0x02|d);//Default=>0x12(0x10)//AlternativeCOMPinConfiguration//DisableCOMLeft/RightRe-Map}voidSet_Contrast_Control(unsignedchard){spi_transfer_nr(0x81);//SetContrastControlspi_transfer_nr(d);//Default=>0x7F}voidSet_Precharge_Period(unsignedchard){spi_transfer_nr(0xD9);//SetPre-ChargePeriodspi_transfer_nr(d);//Default=>0x22(2DisplayClocks[Phase2]/2DisplayClocks[Phase1])//D[3:0]=>Phase1Periodin1~15DisplayClocks//D[7:4]=>Phase2Periodin1~15DisplayClocks}voidSet_VCOMH(unsignedchard){spi_transfer_nr(0xDB);//SetVCOMHDeselectLevelspi_transfer_nr(d);//Default=>0x20(0.77*VCC)}voidSet_Entire_Display(unsignedchard){spi_transfer_nr(0xA4|d);//SetEntireDisplayOn/Off//Default=>0xA4//0xA4(0x00)=>NormalDisplay//0xA5(0x01)=>EntireDisplayOn}voidSet_Inverse_Display(unsignedchard){spi_transfer_nr(0xA6|d);//SetInverseDisplayOn/Off//Default=>0xA6//0xA6(0x00)=>NormalDisplay//0xA7(0x01)=>InverseDisplayOn}voidSet_Start_Column(unsignedchard){spi_transfer_nr(0x00+d%16);//SetLowerColumnStartAddressforPageAddressingMode//Default=>0x00spi_transfer_nr(0x10+d/16);//SetHigherColumnStartAddressforPageAddressingMode//Default=>0x10}voidSet_Start_Page(unsignedchard){spi_transfer_nr(0xB0|d);//SetPageStartAddressforPageAddressingMode//Default=>0xB0(0x00)}voidFill_RAM(unsignedcharData){unsignedchari,j;for(i=0;i<8;i++){Set_Start_Page(i);Set_Start_Column(0x00);for(j=0;j<128;j++){spi_transfer_nr1(Data);}}}voidOLED_Init_I()//VCCGeneratedbyInternalDC/DCCircuit{unsignedchari;RST=0;for(i=0;i<200;i++){delay_us(200);//uDelay(200);}RST=1;Set_Display_On_Off(0x00);//DisplayOff(0x00/0x01)Set_Display_Clock(0x80);//SetClockas100Frames/SecSet_Multiplex_Ratio(0x3F);//1/64Duty(0x0F~0x3F)Set_Display_Offset(0x00);//ShiftMappingRAMCounter(0x00~0x3F)Set_Start_Line(0x00);//SetMappingRAMDisplayStartLine(0x00~0x3F)Set_Charge_Pump(0x04);//EnableEmbeddedDC/DCConverter(0x00/0x04)Set_Addressing_Mode(0x02);//SetPageAddressingMode(0x00/0x01/0x02)Set_Segment_Remap(0x01);//SetSEG/ColumnMapping(0x00/0x01)Set_Common_Remap(0x08);//SetCOM/RowScanDirection(0x00/0x08)Set_Common_Config(0x10);//SetSequentialConfiguration(0x00/0x10)Set_Contrast_Control(Brightness);//SetSEGOutputCurrentSet_Precharge_Period(0xF1);//SetPre-Chargeas15Clocks&Dischargeas1ClockSet_VCOMH(0x40);//SetVCOMDeselectLevelSet_Entire_Display(0x00);//DisableEntireDisplayOn(0x00/0x01)Set_Inverse_Display(0x00);//DisableInverseDisplayOn(0x00/0x01)Fill_RAM(0x00);//ClearScreenSet_Display_On_Off(0x01);//DisplayOn(0x00/0x01)}

Utilicélabombadecarga.entonceselpoderdeOLEDes:

  • 4voltaVbat
  • 3voltaVdd

HeutilizadoelSPI(modode4hilos.Paraobtenermásinformación,puedeverlahojadedatosylosarchivosdecomandos)

en su opinión, ¿cuál es el problema?

    
pregunta Roh

1 respuesta

2

La interfaz con las pantallas es un trabajo duro. Sin pasar horas mirando tu lista, no lo resolveré desde aquí. En orden de importancia

  1. Verifique los voltajes.

  2. Compruebe cuádruple el esquema y las conexiones.

  3. Use el código bueno conocido cuando sea posible.

  4. Si no se puede encontrar el código, haz un paso y una hora.

  5. De cualquier manera (# 3 o # 4) Comience con la lectura de un valor en la pantalla, luego continúe con el siguiente paso, configure el sesgo, etc.

Una vez que cada i está punteada, y cada t cruzada, generalmente funcionan.

    
respondido por el Erik Friesen

Lea otras preguntas en las etiquetas