View previous topic :: View next topic |
Author |
Message |
hzz
Joined: 20 Feb 2007 Posts: 314
|
Posted: Sat Mar 09, 2019 12:46 pm Post subject: Understanding (or not) Timer freq mode |
|
|
In the following code timers E1 and E0 are configured equally; however the outputs at pin PE4 (Timer E1 compare A output) and pin PE0 (Timer E0 compare A output) are very different. Why? (BASCOM 2.0.8.1 - Board Crumb xmega128A3)
Code: | '________________________________________________________________________________
' Test frequency generation to drive a Buzzer
'________________________________________________________________________________
$regfile = "xm128A3Udef.dat"
$hwstack = 256
$swstack = 128
$framesize = 128
'________________________________________________________________________________
' CONFIG SYSTEM CLOCK
Config Osc = Disabled , Extosc = Enabled , Range = 12mhz_16mhz , Startup = Xtal_16kclk , 32khzosc = Enabled , Pllosc = Enabled , Pllsource = Extclock , Pllmul = 2 ' 16x2=32MHz
Config Sysclock = Pll , Prescalea = 1 , Prescalebc = 1_1 ' 32/1=32 MHz
$crystal = 32000000
'________________________________________________________________________________
Config Tce1 = Freq , Prescale = 64 , Comparea = Enabled , Resolution = 16
Tce1_cca = 277
Config Tce0 = Freq , Prescale = 64 , Comparea = Enabled , Resolution = 16
Tce0_cca = 277
'_____________________________________________________________________________
End 'end program |
(BASCOM-AVR version : 2.0.8.1 ) |
|
Back to top |
|
|
hzz
Joined: 20 Feb 2007 Posts: 314
|
Posted: Sat Mar 09, 2019 6:04 pm Post subject: |
|
|
But this does work as expected:
Code: | '________________________________________________________________________________
' Test frequency generation to drive a Buzzer
'________________________________________________________________________________
$regfile = "xm128A3Udef.dat"
$hwstack = 256
$swstack = 128
$framesize = 128
'________________________________________________________________________________
' CONFIG SYSTEM CLOCK
Config Osc = Disabled , Extosc = Enabled , Range = 12mhz_16mhz , Startup = Xtal_16kclk , 32khzosc = Enabled , Pllosc = Enabled , Pllsource = Extclock , Pllmul = 2 ' 16x2=32MHz
Config Sysclock = Pll , Prescalea = 1 , Prescalebc = 1_1 ' 32/1=32 MHz
$crystal = 32000000
'________________________________________________________________________________
Config Tce1 = Freq , Prescale = 64 , Comparea = Enabled , Resolution = 8
Tce1_cca = 88
Config Tce0 = Freq , Prescale = 64 , Comparea = Enabled , Resolution = 8
Tce0_cca = 88
'_____________________________________________________________________________
End 'end program |
It seems that Resolution cannot be put =16 in frequency generation mode |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Mar 10, 2019 5:12 pm Post subject: |
|
|
I'd say what you're doing raises questions, the help tells:
Quote: | RESOLUTION
Valid options : NORMAL, BYTE, SPLIT. |
Nonetheless you put 8 or 16 as option and you wonder about odd behavior?
Beside I was able to find out that by using proper arguments like RESOLUTION = BYTE/NORMAL the code works as desired.
I spared myself the effort to find out what chaotic/nonlinear/miracle side-effects the improper user configuration did create, as it is much less effort if the user simply follows parameter syntax.
In your case also a look into the data sheet would have been advisable, there you would have found:
Quote: | 14.12.5 CTRLE – Control register E
---Bit 1:0 – BYTEM[1:0]: Byte Mode
------These bits select the timer/counter operation mode according to Table 14-7 on page 166 .
---------BYTEM[1:0] Group Configuration Description
------------00 NORMAL Timer/counter is set to normal mode (timer/counter type 0)
------------01 BYTEMODE Upper byte of the counter (CNTH) will be set to zero after each counter clock cycle
------------10 SPLITMODE Timer/counter 0 is split into two 8-bit timer/counters (timer/counter type 2) |
If you compare the keywords with those from the help, it should have rang a bell not to use nonsense values like 8 or 16. |
|
Back to top |
|
|
hzz
Joined: 20 Feb 2007 Posts: 314
|
Posted: Mon Mar 25, 2019 11:00 pm Post subject: |
|
|
Yes, stupid error :oops: |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|