Difference between revisions of "STM32F107VC/Using MCBQVGA-TS-Display-v12"
From Teknologisk videncenter
m |
m |
||
(8 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
#To see Timer 3's possibilities on PB0 look on page 161 section 9.1.11 table 23 it's seen that timer 3 can use a GPIO pin as ''Output Compare Channel X'' when the pin is configured as ''Alternate Function Push-Pull''. | #To see Timer 3's possibilities on PB0 look on page 161 section 9.1.11 table 23 it's seen that timer 3 can use a GPIO pin as ''Output Compare Channel X'' when the pin is configured as ''Alternate Function Push-Pull''. | ||
#To set PB0 as Alternate Function Push-Pull - See the GPIOx_CRL register on page 166. | #To set PB0 as Alternate Function Push-Pull - See the GPIOx_CRL register on page 166. | ||
− | #To configure Timer 3 as continues [[PWM]] output timer see Page 371 section 15.3.9 | + | #To configure Timer 3 as continues [[PWM]] output timer see Page 371 section 15.3.9 |
+ | ===Example code=== | ||
+ | Still experimental and missing documentation | ||
+ | ;Note:To change Pulse Width change the value of '''TIM3->CCR3''' | ||
+ | <source lang=c> | ||
+ | #include "GPIO_STM32F10x.h" | ||
+ | /* | ||
+ | Example 2: | ||
+ | ========== | ||
+ | Using timer 3 to Dim the Backlight in Display | ||
+ | |||
+ | Mode : Continues PWM mode to PB0. Section 15.3.9 page 370 | ||
+ | For details see: http://mars.tekkom.dk/mediawiki/index.php/STM32F107VC/Using_MCBQVGA-TS-Display-v12 | ||
+ | |||
+ | Caveats: Assumes TIMxCLK = 72 MHz (See RCC - Reset And Clock Control) | ||
+ | */ | ||
+ | |||
+ | void tim3init( void ) { | ||
+ | GPIOB->CRL |= 0xa; // Set PB0 as Alternate function Push-Pull | ||
+ | RCC->APB1ENR |= 2; //Enable timer 3 clock (RCC->APB1ENR bit 1 = 1) | ||
+ | |||
+ | |||
+ | TIM3->PSC = 72; // Prescaler: With timer 3 input clock 72 Mhz divide by 72 to 1 Mhz | ||
+ | TIM3->ARR = 1000; // Auto Reload Register set to 1000 divide 1Mhz/1000 = 1 Khz | ||
+ | TIM3->CCR3 = 100; //Compare Register for channel 3 | ||
+ | TIM3->CCMR2 |= 7 << 4; //PWM mode 1 | ||
+ | TIM3->CCMR2 |= 1 << 3; | ||
+ | TIM3->EGR |= 1; //Update generate | ||
+ | TIM3->CCER |= 1<<8; //Polarity | ||
+ | TIM3->CCER |= 1<<9; | ||
+ | TIM3->CR1 |= 1; | ||
+ | } | ||
+ | |||
+ | /* Change Display Backlight Intensity | ||
+ | input: 0 - 17 ( 0 = 0% backlight (All dark) to 17 = 100% backlight (Brigth) | ||
+ | Caveats: No errorcontrol | ||
+ | When 0 the timer should be turned off and the backlight turned off (PB0=0) | ||
+ | when 17 the timer should be turned off and the backlight turned on (PB0=1) | ||
+ | */ | ||
+ | void backlight( int intensity ) { | ||
+ | int disvalarr[] = {0,5,10,15,25,35,50,65,80,100,120,150,200,300,400,600,800,1000}; | ||
+ | TIM3->CCR3 = disvalarr[intensity]; | ||
+ | } | ||
+ | </source> | ||
+ | |||
=Links= | =Links= | ||
*[http://www.keil.com/mcbstm32c/mcbstm32c-display-board-schematics.pdf MCBSTM32C Display Schematics] (Loads PDF) | *[http://www.keil.com/mcbstm32c/mcbstm32c-display-board-schematics.pdf MCBSTM32C Display Schematics] (Loads PDF) | ||
− | *[http:// | + | *[http://gamma.spb.ru/download/AM-240320LDTNQW-T00H.pdf AM-240320LDTNQW TFT-LCD Display module with Touch Panel] (Loads PDF) |
**[http://www.ampdisplay.com/colortft_specs_18to50.html Display modules]?? | **[http://www.ampdisplay.com/colortft_specs_18to50.html Display modules]?? | ||
*[http://www.intelligentdisplay.com/PDFs/SPFD5408B-C3_V04.pdf SPFD5408B 720 channel driver for TFT-LCD Display] (Loads PDF) | *[http://www.intelligentdisplay.com/PDFs/SPFD5408B-C3_V04.pdf SPFD5408B 720 channel driver for TFT-LCD Display] (Loads PDF) | ||
− | *[http://www.st.com/ | + | *[http://www.st.com/content/ccc/resource/technical/document/datasheet/d3/4a/58/38/4f/fa/46/2d/CD00186725.pdf/files/CD00186725.pdf/jcr:content/translations/en.CD00186725.pdf STMPE811 Touch Screen Controller] |
*[http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00098098.pdf STLD40D White LED power supply for large display backlight] (Loads PDF) | *[http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00098098.pdf STLD40D White LED power supply for large display backlight] (Loads PDF) | ||
+ | |||
=References= | =References= | ||
<references/> | <references/> | ||
[[Category:ARM]] | [[Category:ARM]] |
Latest revision as of 10:55, 5 October 2017
Contents
Backlight illumination adjust
The signal BL_control[1] turns on the Backlight LED's controlled by the STLD40D[2] IC on the display. To control the illuminace of the LED's its necessary to turn the LED's off and on using Pulse-Width-Modulation (PWM).
Keil MCBSTM32C board
On the Keil MCBSTM32C board the BL_control signal is connected to PB0 (Port B bit 0).
- Looking in the Reference Maual on page 173 section 9.3.7 table 44 it's seen that Timer 3 Channel 3 has an alternate function on PB0.
- To see Timer 3's possibilities on PB0 look on page 161 section 9.1.11 table 23 it's seen that timer 3 can use a GPIO pin as Output Compare Channel X when the pin is configured as Alternate Function Push-Pull.
- To set PB0 as Alternate Function Push-Pull - See the GPIOx_CRL register on page 166.
- To configure Timer 3 as continues PWM output timer see Page 371 section 15.3.9
Example code
Still experimental and missing documentation
- Note
- To change Pulse Width change the value of TIM3->CCR3
#include "GPIO_STM32F10x.h"
/*
Example 2:
==========
Using timer 3 to Dim the Backlight in Display
Mode : Continues PWM mode to PB0. Section 15.3.9 page 370
For details see: http://mars.tekkom.dk/mediawiki/index.php/STM32F107VC/Using_MCBQVGA-TS-Display-v12
Caveats: Assumes TIMxCLK = 72 MHz (See RCC - Reset And Clock Control)
*/
void tim3init( void ) {
GPIOB->CRL |= 0xa; // Set PB0 as Alternate function Push-Pull
RCC->APB1ENR |= 2; //Enable timer 3 clock (RCC->APB1ENR bit 1 = 1)
TIM3->PSC = 72; // Prescaler: With timer 3 input clock 72 Mhz divide by 72 to 1 Mhz
TIM3->ARR = 1000; // Auto Reload Register set to 1000 divide 1Mhz/1000 = 1 Khz
TIM3->CCR3 = 100; //Compare Register for channel 3
TIM3->CCMR2 |= 7 << 4; //PWM mode 1
TIM3->CCMR2 |= 1 << 3;
TIM3->EGR |= 1; //Update generate
TIM3->CCER |= 1<<8; //Polarity
TIM3->CCER |= 1<<9;
TIM3->CR1 |= 1;
}
/* Change Display Backlight Intensity
input: 0 - 17 ( 0 = 0% backlight (All dark) to 17 = 100% backlight (Brigth)
Caveats: No errorcontrol
When 0 the timer should be turned off and the backlight turned off (PB0=0)
when 17 the timer should be turned off and the backlight turned on (PB0=1)
*/
void backlight( int intensity ) {
int disvalarr[] = {0,5,10,15,25,35,50,65,80,100,120,150,200,300,400,600,800,1000};
TIM3->CCR3 = disvalarr[intensity];
}
Links
- MCBSTM32C Display Schematics (Loads PDF)
- AM-240320LDTNQW TFT-LCD Display module with Touch Panel (Loads PDF)
- SPFD5408B 720 channel driver for TFT-LCD Display (Loads PDF)
- STMPE811 Touch Screen Controller
- STLD40D White LED power supply for large display backlight (Loads PDF)