emulating a OLED display on a VGA and/or a LCD monitor

Post here all questions related to LibMaple core if you can't find a relevant section!
Y@@J
Posts: 57
Joined: Mon Sep 28, 2020 8:51 pm

Re: BluePill as I²C slave with Roger's Core

Post by Y@@J »

SPI cannot be used, because on the Nano it's registers are in use for video signals. My first idea was parallel (enough pins for parallel, probably 8bit, and some flow control).
I'd like to try I²C because it's a bit easier (flow control comes with) and I'm lazy, and also because on the Nano it runs on ports untouched by TVOut : I quickly read the sources from nootropic Nunchuk support for the Nano + TVOut retrogaming console ; it appears tricky on the master, but the hard work is done !
So, I'll give it a try, and turn the STM32 into a big Nunchuk. Just to see what can be transfered between two video frames before the image gets out of sync.
There's no need to transfer the whole 1KB at once. 60 fps is a lot. Should work if 10 to 20 intervals are enough to update the video buffer. 50-100ms total for 1KB is 10 to 20KB/s (not including all the opening/closing I²C communication function calls).
Will go for parallel if it does not work, or if too slow, or display too laggy.

Please guys, don't help me too much at this point. I wouldn't have had any success on the first part of the project (SPI and DMA) without, but I should be able to do the second part ! And if it goes parallel, I will learn STM32 port manipulation (never did it with STM32, only with Arduinos).
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: BluePill as I²C slave with Roger's Core

Post by ag123 »

normally i2c is 100kbps or 400kbps
https://www.i2c-bus.org/speed/
stm's uart easily exceed that
i2c is normally used if you have multiple devices on the same 2 wire bus, otherwise it is probably easier to deal with point to point protocols
normaly uart (i'm not sure about i2c and spi) buffers 1 byte of data, and if you are exploring cycle stealing, you might as well use a stm32 for both ends as it has dma. not every mcu has dma, stm32 is one of those that has it, it is one of the strong features of stm32
Y@@J
Posts: 57
Joined: Mon Sep 28, 2020 8:51 pm

Re: BluePill as I²C slave with Roger's Core

Post by Y@@J »

Test with I2C/Nunchuk object : just asking for data takes 250µs, the launch window being 5ms (measured with a logic analyzer); nunchuk class I2C clock = 100kHz (measured). Can be used for a pair of bytes ! Parallel is the only way to go, at extreme speeds.
Work this way : set a flag within vertical blanking, comm. being done when loop() is called.
Dreaming of a memory being shared between the STM32 and the Nano...

This is just a follow up, not asking for help !!!! Want to experiment !
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: BluePill as I²C slave with Roger's Core

Post by stevestrong »

This is not an answer, just an idea :)

What about using software serial on nano, you need only Rx on Nano and Tx on STM (HW USART), no flow control needed, uses only one GPIO and you can go up with transfer speed higher than 400kbps.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: BluePill as I²C slave with Roger's Core

Post by ag123 »

and for 'parallel' on stm32's end, it is usually a h/w timer that drives the dma
i used that technique in this project
https://github.com/ag88/SumpSTM32F401cc
it works very well, but in my case i'm reading data as i'm using it as a logic analyzer.
i'd guess the reverse could be true too.
your timer is the clock signal as well as that it drives dma to send data out on gpio pins
the details of that 'parallel' technique is discussed in this appnote
https://www.st.com/resource/en/applicat ... ronics.pdf
accordingly it is even possible to use the h/w timer in to sync on a clock train as input to receive/send the 'parallel' data discussed in the app note
it is one of the less explored features of stm32
i'm wanting to use this for ov7670 and the larger (e.g. ov2640 2mp) camera modules
https://www.arducam.com/wp-content/uplo ... evc_ds.pdf
https://www.arducam.com/product/2mp-ov2 ... ra-module/
have not found time to mess with that yet
Y@@J
Posts: 57
Joined: Mon Sep 28, 2020 8:51 pm

Re: BluePill as I²C slave with Roger's Core

Post by Y@@J »

This what I'm doing :

- parallel (8bit)
- when the client is ready to receive video data (V-Sync), it sends a request to the master
- the master activates a line asking for data (data send request)
- the client acitvates a line while transmmitting a frame
- it also generates a clock, high for every byte

Can be fast.

This the fastest I can get for 1KB (for now with a Nano, will switch to a STM32 soon) ; have to slow down a bit to get it to be decoded on the other end, and if TVOut is not in use. Faster than 4.5ms = out of sync. TVOut does not really like it. To be continued. have to see how many pages will be needed, and what the maximum frequency can be. All the needed functions are written.

Promising.
frame_parallel.JPG
frame_parallel.JPG (87.15 KiB) Viewed 4194 times
Now leanring direct port access with the STM32...

Faster, and more recognizable pattern :
Attachments
frame_parallel 2.JPG
frame_parallel 2.JPG (80.35 KiB) Viewed 4193 times
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: BluePill as I²C slave with Roger's Core

Post by stevestrong »

You may consider DMA to receive the parallel data on STM32, I have implemented such a configuration to receive data from OV7670, see here an example.
Y@@J
Posts: 57
Joined: Mon Sep 28, 2020 8:51 pm

Re: BluePill as I²C slave with Roger's Core

Post by Y@@J »

The STM32 does not receive parallel data. It sends them to a Nano that acts as a video adapter.
The STM32 receives display data over SPI from a 3D printer board. The data are decoded, formated, and sent to a Nano running the TVOut library, and then are displayed on a LCD touchscreen shared with OctoPrint. If I was able to make the STM32 generate NTSC composite, or 800x600 monochrome VGA, there wouldn't be any need for a Nano ! AFAIK, 800x600 VGA has been done with the Arduino Due, but it has only one SPI channel (2 on hardware, but only one usable). Need two. Need one SPI input (OLED signals) and one SPI output (composite NTSC video or 800x600 VGA). It's a basic 1 inch-ich SSD1306 OLED emulator that has to display on a large video LCD.

Currently rewiring the breadboards for real life tests, and crossing fingers (and toes).

We are now out of topic. Maybe the moderators won't like it ! The I²C topic was created because the other thread I opened was about SPI and DMA...

Merry Chrismas !
(will have a hot air station !)
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: BluePill as I²C slave with Roger's Core

Post by ag123 »

i did a little google and stumbled into these
http://www.davidcranor.com/thinner-client/
https://forum.allaboutcircuits.com/thre ... ps.126986/
http://www.hpcc.ecs.soton.ac.uk/dan/pic/video_PIC.htm
https://www.onsemi.com/pub/Collateral/AND8261-D.PDF
http://www.kolumbus.fi/pami1/video/pal_ntsc.html
https://code.google.com/archive/p/arduino-tvout/
https://github.com/Avamander/arduino-tvout
https://www.artekit.eu/vga-output-using-a-36-pin-stm32/
i'm not familiar with analog video signals but i've a strange feeling if you aren't too fussy with color
and use a fast stm32 say f407, f405 etc with its dac, it maybe possible to do that with the on chip dac
you could probably do everything on a single chip
https://www.youtube.com/watch?v=GoTuMJFUb7g
https://github.com/eprive/STM32Lvideo
https://www.youtube.com/results?search_ ... site+video
apparently it could be done without a dac, probably simply switching a dot on or off
https://github.com/eprive/STM32Lvideo/wiki
;)
Merry X'mas
Y@@J
Posts: 57
Joined: Mon Sep 28, 2020 8:51 pm

Re: BluePill as I²C slave with Roger's Core

Post by Y@@J »

Thanks for the links, I will read ASAP, but I am unable to code that in asm. All I did with asm was coding in C, then generating asm, and doing some basic optimisation. Nothing more, and very long ago for x86 ! Learning how to do this, or learning how to do it with a RasPi, the RasPi is definitely the way to go.

This being said I succeded with the Nano as a video card using TVOut. The thing is alive but sub optimal. Would be better if the STM32 could generate the video signal !
The parallel transfers are a bit slow. 330kHz is not enough ; speed is limited by delayMicroseconds granularity. 1MHz would be better. Tried some "stopwatch" code I found on the web, with no success. Miss some SPI data (because of data conversions and tranfers). Also considering overclocking at 120MHz. Or use a larger SPI buffer. And some optimisation (currently SPI buffer -> conversion to OLEDish buffer (using memcpy and removing some control codes) -> conversion to 1bit bitmap for TVOut. Data being 1bit bitmaps with few white pixels, RLE encoding could also help. Because for now it is too laggy to be really usable.

Will shoot a short video and post some code tomorrow.

I'm a bit confused, because I first opened a thread about SPI, then this one about I²C. We are now now off topic. Maybe a moderator could merge the two topics ? The project is a SSD1306 OLED emulator. Now near to complete, usable or not.
Post Reply

Return to “General discussion”