Skip to main content
FEkic
Associate II
August 3, 2019
Question

VGA not working?

  • August 3, 2019
  • 1 reply
  • 764 views

I am trying to give 800x600@56hz vga output with my stm32f103c8t6. For some reason I can't get it to work. Both of the monitors I tried are saying "Input is not supported" or sth along thoose lines.I know that they can work with 800x600@56hz. I have tried other resolutions and I couldn't get any of them to work. In some of my tries I got 800x600 54hz,68hz and 72hz.This happened when I tried to speed up the 640x480@60hz numbers but I couldn't get the desired resolution and the other random ones I got were inconsistent. Here is my code:

 .thumb
 .syntax unified
 .equ GPIOB,0x40010C00
 .equ GPIOA,0x40010800
 .equ RCC ,0x40021000
 .equ TIM3 ,0x40000400
 .equ TIM2 ,0x40000000
 .equ NVIC ,0xE000E100
 .equ DMA1 ,0x40020000
 
 .type ramres,%function
 .global ramres
ramres:
 mov R1,0
 ldr R0,=0x20000000
 ldr R2,=0x20005000
ramres1:
 str R1,[R0],4
 cmp R0,R2
 bne ramres1
 bx lr
 .size ramres,.-ramres
 .global main
main:
 ldr R0,=RCC
 mov R1,15
 str R1,[R0,0x14] //set the DMA1 Clock || RCC_AHBENR
 mov R1,0b1100
 str R1,[R0,0x18] //set the GPIOB,GPIOA Clocks || RCC_APB2ENR
 mov R1,0b11
 str R1,[R0,0x1C] //set the TIM2 and TIM3 Clocks || RCC_APB1ENR
 
 add lr,pc,5
 b ramres
 
 mov R0,0x20000000
 mov R1,896
 strh R1,[R0]
 mov R1,824
 strh R1,[R0,0x2]
 ldr R1,=601
 strh R1,[R0,0x4]
 add R1,R1,2
 strh R1,[R0,0x6]
 
 ldr R0,=DMA1
 
 mov R1,2
 str R1,[R0,0x84] //NDT = 2 || DMA1_CNDTR7
 ldr R1,=0x40000034 // TIM2_CCR1
 str R1,[R0,0x88] // DMA1_CPAR7ldr R2,=TIM2
 mov R1,0x20000000
 str R1,[R0,0x8C] // DMA1_CMAR7
 ldr R1,=13745 //0 11 01 01 1 0 1 1 0 0 0 1
 str R1,[R0,0x80] //configuring channel7 || DMA1_CRR7
 
 mov R1,1
 str R1,[R0,0x34] //NDT = 1 || DMA1_CNDTR3
 str R1,[R0,0x70] //NDT = 1 || DMA1_CNDTR6
 ldr R1,=0x4000043C // TIM3_CCR3
 str R1,[R0,0x38] // DMA1_CPAR3
 str R1,[R0,0x74] // DMA1_CPAR6
 ldr R1,=0x20000004
 str R1,[R0,0x78] // DMA1_CMAR6
 add R1,R1,2
 str R1,[R0,0x3C] // DMA1_CMAR3
 ldr R1,=13617 //0 11 01 01 0 0 1 1 0 0 0 1
 str R1,[R0,0x30] //configuring channel3 || DMA1_CCR3
 str R1,[R0,0x6C] //configuring channel6 || DMA1_CCR6
 
 //channel 6 -> tim3 channel 1
 //channel 3 -> tim3 channel 4
 //PB0 -> tim3 channel 3
 //tim2 will be prescaler for tim3
 ldr R0,=TIM2
 mov R1,1
 str R1,[R0,0x28] //set the prescaler to 1 || TIM2_PSC
 mov R1,1024
 str R1,[R0,0x2C] //set the ARR to 1024 || TIM2_ARR
 mov R1,824
 str R1,[R0,0x34] //set the CCR1 to 824 || TIM2_CCR1
 mov R1,840
 str R1,[R0,0x38] //set the CCR2 to 840 || TIM2_CCR2 (CCR1 -> 896)
 ldr R1,=920
 str R1,[R0,0x40] //set the CCR4 to 920 || TIM2_CCR4 (CCR1 -> 824)
 mov R1,0b1
 str R1,[R0,0x20] //enable the CC1|| TIM2_CCER
 mov R1,0x30
 str R1,[R0,0x18] //set OC1M to 011(toggle) || TIM2_CCMR1
 mov R1,5120
 str R1,[R0,0x0C] //enable the DMA's || TIM2_DIER
 mov R1,32
 str R1,[R0,0x04] //set MMS to 010 || TIM2_CR2
 mov R1,0b01
 str R1,[R0] //enable the counter || TIM2_CR1
 
 ldr R0,=TIM3
 ldr R1,=625
 str R1,[R0,0x2C] //set the ARR to 625 || TIM3_ARR
 ldr R1,=605
 str R1,[R0,0x34] //set the CCR1 to 605 || TIM3_CCR1 (CCR3 -> 601)
 ldr R1,=601
 str R1,[R0,0x3C] //set the CCR3 to 601 || TIM3_CCR3
 ldr R1,=602
 str R1,[R0,0x40] //set the CCR4 to 602 || TIM3_CCR4 (CCR3 -> 603)
 mov R1,256
 str R1,[R0,0x20] //enable the CC3|| TIM3_CCER
 mov R1,0x30
 str R1,[R0,0x1C] //set OC3M to 011(toggle) || TIM3_CCMR2
 mov R1,4608
 str R1,[R0,0x0C] //enable the DMA's || TIM3_DIER
 mov R1,23
 str R1,[R0,0x08] //TS = 001 SMS = 111 || TIM3_SMCR
 mov R1,0b01
 str R1,[R0] //enable the counter || TIM3_CR1
 
 ldr R0,=GPIOB
 ldr R1,=0x44444444B
 str R1,[R0]
 
 ldr R0,=GPIOA
 ldr R1,=0x4222222B
 str R1,[R0]
wow:
 b wow

I can confirm that the MCU is running at 72mhz. The PA0 is connected to HSYNC and PB0 is connected to VSYNC. PA1to6 are connected to an DAC that I made with resistors but for now they are irrelevant. I would really appreciate anyone that can help cause I have no idea why this is not working

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
August 3, 2019

Do you have an oscilloscope?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
FEkic
FEkicAuthor
Associate II
August 3, 2019

Unfortunantly I dont ;(