SSD1306 I2C with Pic16f1937!

For general Flowcode discussion that does not belong in the other sections.
mnfisher
Valued Contributor
Posts: 1462
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

Re: SSD1306 I2C with Pic16f1937!

Post by mnfisher »

Thanks to Ben and Jorgen,

I got up and running on an ATTiny85 - but not on ATTiny13. Seems that i2c is not supported. Have to find a 24 or something with USI support :-(
For the '85 - I added a small delay to the beginning of initialise to allow the power to stablilise to the display (not sure if it's actually needed)

I clocked the MCU at 16MHz (internal - this isn't an option in FC but set the fuses from Arduino IDE). I notice the clock options in build properties are a bit odd (lots of ATTiny15 options?)

I also shrank the charset lookup and PrintChar displays lower case characters as upper case (not sure if this is really needed).

Have a PIC16LF15313 with 3.5KB flash and 256bytes of RAM - will give it a whirl too :-)

Will also try and find one of the larger (64 pixel height) displays to test.

Martin

jgu1
Posts: 777
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 670 times
Been thanked: 175 times

Re: SSD1306 I2C with Pic16f1937!

Post by jgu1 »

hi Martin!

As promised a test with your program. I have change the SDA to A0 And SCL to A1. I can compile without memory error, but no lifet in the display :)

To ensure that the program run, I added one sec flasher for test in the program, it work.

Br jorgen
Attachments
ssd1306_min.fcfx
(35.12 KiB) Downloaded 177 times

mnfisher
Valued Contributor
Posts: 1462
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

Re: SSD1306 I2C with Pic16f1937!

Post by mnfisher »

:-(

Which display do you have (32 or 64 pixel). Ca you check the i2c output on an oscilloscope (when I tried the ATTiny I had SDA and SCL the wrong way round - which took longer to notice than I like to admit)
I'll try with a PIC this evening if I get time...

Martin

chipfryer27
Valued Contributor
Posts: 1528
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 353 times
Been thanked: 549 times

Re: SSD1306 I2C with Pic16f1937!

Post by chipfryer27 »

Hi

Pretty sure I have a 1937 and I know I have a 32p 1306. If you still need testing I can probably have a look at the weekend.

Regards

mnfisher
Valued Contributor
Posts: 1462
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

Re: SSD1306 I2C with Pic16f1937!

Post by mnfisher »

Thanks Iain.

Jorgen - try adding a 100ms delay to the start of initialise - the display needs a short delay after VDD is applied - and if the chip starts quickly (unlike Arduino) it might start sending data too soon?

Martin

chipfryer27
Valued Contributor
Posts: 1528
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 353 times
Been thanked: 549 times

Re: SSD1306 I2C with Pic16f1937!

Post by chipfryer27 »

Hi

I'm pretty sure the 32p version works with a 1939 as that chip is pretty much a resident in one of my multi-programmers and would certainly have been used with the display at some point (as too a 18877). Those would have either been operating from the on-board crystal (8MHz or 19.xxMHz) or set internally probably to 8MHz or 32MHz.

The 1937 isn't too disimilar to the 39 so hopefully there isn't any issue.

Regards

jgu1
Posts: 777
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 670 times
Been thanked: 175 times

Re: SSD1306 I2C with Pic16f1937!

Post by jgu1 »

Hi Martin and Lian

Sorry, my fault, SDA and SCL I have forgot to flip. Sorry now it work ;) And wow, what a speed,superfast :D
Is it possible to create a component macro based on your way to handle this display Martin?


Jorgen
Attachments
ssd1306_min.fcfx
(35.12 KiB) Downloaded 175 times

mnfisher
Valued Contributor
Posts: 1462
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

Re: SSD1306 I2C with Pic16f1937!

Post by mnfisher »

Cool - glad it's working.

Yes - it could be made into a component easily.. Will have a try tonight (or have a go - all the source is there?)

Martin

mnfisher
Valued Contributor
Posts: 1462
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

Re: SSD1306 I2C with Pic16f1937!

Post by mnfisher »

As a tiny component.

I added a PrintNumber.
Changed Interlaced to inverted - since on my display this is what it seems to do.

And - I allowed myself the luxury of a 9 byte buffer - so now a charqcter is sent as one transaction of 9 bytes instead of 8 of 2.

Added a tiny test program. Displays a rotating string - it really needs a delay in the loop - I used 50ms - adjust to suit your eyes. Then clears the display and draws some numbers and text.

Now seems to work at 400kHz.
ssd_test.fcfx
(12.31 KiB) Downloaded 173 times
SSD1306_Min.fcpx
(4.72 KiB) Downloaded 179 times
ssd1306_min.fcfx
(34.64 KiB) Downloaded 182 times

To add the component - save the .fcpx file to a location (say c:\FC_Components) - and add this location to Customise - locations - look for components in. Restart FC and you should be able to find the new component (search for SSD1396 - it's called SSD1306 Text or look in Displays - Alphanumeric)

Simulation doesn't do anything - the source is there if anyone would like to play...

Martin

mnfisher
Valued Contributor
Posts: 1462
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

Re: SSD1306 I2C with Pic16f1937!

Post by mnfisher »

I tried (and failed) to display the alternate pins option for i2c pins. ?

Also note that the i2c address of 0x3C is different to the SSD1306 component (which has 2 x 0x3C) - the docs show the unshifted value and I used this - the FC component uses the shifted value.

Post Reply