From a7179f5b77ab2b4bdad60477055893ca6a13f865 Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 8 Jan 2015 00:52:21 -0500 Subject: [PATCH] Tested fix for PWM_BACKLIGHT on ATmega2561 MCUs The functionality of timer0 and timer2 are switched between ATmega64/128 and 641/1281/2561. When compiled for ATmega2561, this commit sets up timer0 in the same way as timer2 on ATmega64/128 (phase correct PWM, clk/64 count rate, inverted if SP22 is defined). The previous quick fix had a typo in the initialization of TCCR0B (0b111 is an invalid value for the clock select bits CS2:0). It also did not respect the SP22 define which indicates the PWM must be inverted. Smartieparts v2.2 or later programmer boards have an inverted backlight driver. Finally, it is unnecessary to set DDB7 as it is already set in boardInit() (line 101). --- radio/src/targets/stock/board_stock.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/radio/src/targets/stock/board_stock.cpp b/radio/src/targets/stock/board_stock.cpp index 919b2858c..6ff848a10 100644 --- a/radio/src/targets/stock/board_stock.cpp +++ b/radio/src/targets/stock/board_stock.cpp @@ -131,15 +131,18 @@ inline void boardInit() #elif defined(PWM_BACKLIGHT) /** Smartieparts LED Backlight is connected to PORTB/pin7, which can be used as pwm output of timer2 **/ #if defined(CPUM2561) - TCCR0A = (1<