Difference between revisions of "STM32F107VC/Using MCBQVGA-TS-Display-v12"

From Teknologisk videncenter
Jump to: navigation, search
m
m (Keil MCBSTM32C board)
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->ARR'''
 +
<source lang=c>
 +
 
 +
void tim3init( void ) {
 +
int i;
 +
GPIOB->CRL |= 0xa;
 +
//GPIOB->CRL |= ~(0x5);
 +
 
 +
// Step  2: Enable timer 3 clock (RCC->APB1ENR bit 0 = 1)
 +
RCC->APB1ENR |= 2;
 +
 +
    // Step  5: TIM2_ARR = 10000 (Autload Register 10000 - 1 timeout/sek for testing)
 +
// Step  4: TIM2_PSC = 3600 (Prescale to 10000)
 +
TIM3->PSC = 72;
 +
TIM3->ARR = 1000;
 +
TIM3->CCR3 = 100;
 +
TIM3->CCMR2 |= 7 << 4; //PWM mode 1
 +
TIM3->CCMR2 |= 1 << 3;
 +
TIM3->EGR |= 1;
 +
TIM3->CCER |= 1<<8; //Polarity
 +
TIM3->CCER |= 1<<9;
 +
 +
 +
 +
 
 +
// Step  3: Enable Counter (TIM3_CR1 bit 0 = 1)
 +
TIM3->CR1 |= 1;
 +
}
 +
</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)

Revision as of 16:24, 19 January 2012

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).

  1. 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.
  2. 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.
  3. To set PB0 as Alternate Function Push-Pull - See the GPIOx_CRL register on page 166.
  4. 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->ARR
void tim3init( void ) {
	int i;
	GPIOB->CRL |= 0xa;
	//GPIOB->CRL |= ~(0x5);

	// Step  2: Enable timer 3 clock 	(RCC->APB1ENR bit 0 = 1)
	RCC->APB1ENR |= 2;
		
    // Step  5: TIM2_ARR = 10000 (Autload Register 10000 - 1 timeout/sek for testing)
	// Step  4: TIM2_PSC = 3600 (Prescale to 10000)
	TIM3->PSC = 72;
	TIM3->ARR = 1000;
	TIM3->CCR3 = 100;
	TIM3->CCMR2 |= 7 << 4; //PWM mode 1
	TIM3->CCMR2 |= 1 << 3;
	TIM3->EGR |= 1;
	TIM3->CCER |= 1<<8; //Polarity
	TIM3->CCER |= 1<<9;
	
	
	

	// Step  3: Enable Counter 		(TIM3_CR1 bit 0 = 1)
	TIM3->CR1 |= 1;
}

Links

References