STM32 TVout Upgrade to Work with Video Overlay - Help Needed
Posted: Thu Dec 15, 2022 4:32 pm
Hi All,
I'm attempting to get the STM32 based TVOUT library (https://github.com/Tamakichi/ArduinoSTM32_TVout) to work or overlay onto a composite video images.
This is similar to the OverlayDemo sketch in (https://github.com/nootropicdesign/arduino-tvout-ve). HOWEVER this only works with ATMEGA chips, due to the differences with the register.
The OverlayDemo uses the falling edge of an external signal (from an LM1881 Video Sync Separator chip) to reset the output timer.
My code is below. Any help with this is greatly appreciated.
//STM32F103 TVOUT Mod to work with composite video overlay
#include <TTVout.h> //https://github.com/Tamakichi/ArduinoSTM32_TVout
#include <fontALL.h>
TTVout TV;
int zOff = 150;
int xOff = 0;
int yOff = 0;
int cSize = 50;
int view_plane = 64;
float angle = PI/60;
uint16_t cube2d[8][2];
void setup() {
pinMode(PB12, INPUT); //External Intrrupt Pin for reading LM1881 Video Sync Seperator chip
Serial.begin();
delay(1000);
//TV.adjust(2); // NTSC垂直同期補正(スクロールする場合)
//TV.begin(SC_448x216);
//TV.begin(SC_448x108);
//TV.begin(SC_224x216);
TV.begin(SC_224x108);
//TV.begin(SC_112x108);
TV.select_font(font6x8);
TV.println("I am the TVout\nlibrary running on a freeduino\n");
TV.delay(2500);
TV.println("I generate a PAL\nor NTSC composite video using\ninterrupts\n");
TV.delay(2500);
TV.clear_screen();
TV.println("Lets see what\nwhat I can do");
TV.delay(2000);
ExternalIntrruptSetup();
}
void loop() {
}
//Creating an Interrupt to reset or align the start of the NTSC TV overlay output with the camera composite video Vertical Sync Outpout signal
//The vertical sync signal will comes from a LM1881 Video Sync Seperator chip
void ExternalIntrruptSetup() {
attachInterrupt(digitalPinToInterrupt(PB12), StartOfNewFrame, FALLING);
}
// The code in this sub was copied from https://github.com/nootropicdesign/arduino-tvout-ve OverlayDemo sketch
// It was inteneded to initialize ATMega registers for video overlay capability.
// In order to work with STM32F103, I think I need to change this somehow for the STM registers?
void StartOfNewFrame() {
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
TCCR1B = _BV(CS10);
// Enable input capture interrupt
TIMSK1 |= _BV(ICIE1);
// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC01);
}
// Required to reset the scan line when the vertical sync occurs
ISR(INT0_vect) {
display.scanLine = 0;
}
I'm attempting to get the STM32 based TVOUT library (https://github.com/Tamakichi/ArduinoSTM32_TVout) to work or overlay onto a composite video images.
This is similar to the OverlayDemo sketch in (https://github.com/nootropicdesign/arduino-tvout-ve). HOWEVER this only works with ATMEGA chips, due to the differences with the register.
The OverlayDemo uses the falling edge of an external signal (from an LM1881 Video Sync Separator chip) to reset the output timer.
My code is below. Any help with this is greatly appreciated.
//STM32F103 TVOUT Mod to work with composite video overlay
#include <TTVout.h> //https://github.com/Tamakichi/ArduinoSTM32_TVout
#include <fontALL.h>
TTVout TV;
int zOff = 150;
int xOff = 0;
int yOff = 0;
int cSize = 50;
int view_plane = 64;
float angle = PI/60;
uint16_t cube2d[8][2];
void setup() {
pinMode(PB12, INPUT); //External Intrrupt Pin for reading LM1881 Video Sync Seperator chip
Serial.begin();
delay(1000);
//TV.adjust(2); // NTSC垂直同期補正(スクロールする場合)
//TV.begin(SC_448x216);
//TV.begin(SC_448x108);
//TV.begin(SC_224x216);
TV.begin(SC_224x108);
//TV.begin(SC_112x108);
TV.select_font(font6x8);
TV.println("I am the TVout\nlibrary running on a freeduino\n");
TV.delay(2500);
TV.println("I generate a PAL\nor NTSC composite video using\ninterrupts\n");
TV.delay(2500);
TV.clear_screen();
TV.println("Lets see what\nwhat I can do");
TV.delay(2000);
ExternalIntrruptSetup();
}
void loop() {
}
//Creating an Interrupt to reset or align the start of the NTSC TV overlay output with the camera composite video Vertical Sync Outpout signal
//The vertical sync signal will comes from a LM1881 Video Sync Seperator chip
void ExternalIntrruptSetup() {
attachInterrupt(digitalPinToInterrupt(PB12), StartOfNewFrame, FALLING);
}
// The code in this sub was copied from https://github.com/nootropicdesign/arduino-tvout-ve OverlayDemo sketch
// It was inteneded to initialize ATMega registers for video overlay capability.
// In order to work with STM32F103, I think I need to change this somehow for the STM registers?
void StartOfNewFrame() {
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
TCCR1B = _BV(CS10);
// Enable input capture interrupt
TIMSK1 |= _BV(ICIE1);
// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC01);
}
// Required to reset the scan line when the vertical sync occurs
ISR(INT0_vect) {
display.scanLine = 0;
}