Vizier87
Active Member
Hi guys, been a while.
I'm attempting to run an SSD1306 display with this tutorial. The programs compiled pretty ok I guess. The PIC I'm using is PIC16F1938.
The display I'm using didn't have the RST/CS pins. Only SCL, SDA, Vcc and GND pins.
Here's the code:
After compiling and burning the .HEX, didn't work. That's fine, troubleshooting then.
Then I checked RC3 and RC4 with a scope. No signals/clocked output observed, just a DC output.
So I tried checked the I2C hardware by a simple library code:
And no clocked signals either from RC3 or RC4.
Anyone can point me in the right direction here?
Thanks.
Vizier87
I'm attempting to run an SSD1306 display with this tutorial. The programs compiled pretty ok I guess. The PIC I'm using is PIC16F1938.
The display I'm using didn't have the RST/CS pins. Only SCL, SDA, Vcc and GND pins.
Here's the code:
C:
/**************************************************************************************
Interfacing PIC16F887 microcontroller with SSD1306 OLED display
C Code for mikroC PRO for PIC compiler
Internal oscillator used @ 8MHz
Configuration words: CONFIG1 = 0x2CD4
CONFIG2 = 0x0700
This is a free software with NO WARRANTY.
http://simple-circuit.com/
***************************************************************************************/
// define SSD1306 reset pin (if available)
//#define SSD1306_RST RD4_bit
//#define SSD1306_RST_DIR TRISD4_bit
#include <SSD1306.c> // include SSD1306 OLED driver source file
char *text = "000\0"; // '\0' is the string terminator
unsigned short i = 0;
int i_= 0;
sbit Indicator at rb4_bit;
void Alert (unsigned int z){
for (i_ = 0; i_ < z; i_++){
Indicator = 1;
Delay_ms(1000);
Indicator = 0;
Delay_ms(1000);
}
Indicator = 0;
}
void main() {
trisb4_bit = 0;
Alert(3);
trisc = 0;
portc = 0;
delay_ms(500); // wait half a second
I2C1_Init(400000); // initialize I2C communication with clock frequency of 400KHz
// initialize the SSD1306 OLED with an I2C addr = 0x7A (default address)
SSD1306_Init(SSD1306_SWITCHCAPVCC, SSD1306_I2C_ADDRESS);
// clear the screen
SSD1306_ClearDisplay();
SSD1306_GotoXY(1, 1); // move cursor to column 1, row 1
SSD1306_Print("Interfacing PIC16F887 with SSD1306 OLED display"); // print text
delay_ms(5000); // wait 5 seconds
// clear the screen
SSD1306_ClearDisplay();
SSD1306_GotoXY(6, 2); // move cursor to column 6, row 2
SSD1306_Print("Hello world!");
delay_ms(2000);
SSD1306_StartScrollRight(1, 1);
delay_ms(3000);
SSD1306_StopScroll();
SSD1306_StartScrollLeft(1, 1);
delay_ms(3000);
SSD1306_StopScroll();
SSD1306_StartScrollDiagRight(1, 1);
delay_ms(3000);
SSD1306_StopScroll();
SSD1306_StartScrollDiagLeft(1, 1);
delay_ms(3000);
SSD1306_StopScroll();
delay_ms(3000);
SSD1306_ClearDisplay();
SSD1306_GotoXY(6, 2);
SSD1306_Print("Hello world!");
delay_ms(2000);
while(1) {
text[0] = (i / 100) % 10 + '0'; // extract hundreds digit
text[1] = (i / 10) % 10 + '0'; // extract tens digit
text[2] = i % 10 + '0'; // extract ones digit
SSD1306_GotoXY(10, 5);
SSD1306_Print(text);
i += 1; // increment i
delay_ms(500);
}
}
// End of code.
After compiling and burning the .HEX, didn't work. That's fine, troubleshooting then.
Then I checked RC3 and RC4 with a scope. No signals/clocked output observed, just a DC output.
So I tried checked the I2C hardware by a simple library code:
C:
void main(){
trisc = 0;
portc = 0;
PORTB = 0;
TRISB = 0; // Configure PORTB as output
I2C1_Init(100000); // initialize I2C communication
I2C1_Start(); // issue I2C start signal
I2C1_Wr(0xA2); // send byte via I2C (device address + W)
I2C1_Wr(2); // send byte (address of EEPROM location)
while (1){
I2C1_Wr(0xAA); // send data (data to be written)
I2C1_Stop(); // issue I2C stop signal Delay_100ms();
I2C1_Start(); // issue I2C start signal
I2C1_Wr(0xA2); // send byte via I2C (device address + W)
I2C1_Wr(2); // send byte (data address)
I2C1_Repeated_Start(); // issue I2C signal repeated start
I2C1_Wr(0xA3); // send byte (device address + R)
PORTB = I2C1_Rd(0u); // Read the data (NO acknowledge)
I2C1_Stop(); // issue I2C stop signal
}
}
And no clocked signals either from RC3 or RC4.
Anyone can point me in the right direction here?
Thanks.
Vizier87