Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20867

BASCOM-AVR : Xmega TcD0 configuration results : NEWTOPIC

$
0
0
Currently moving a ATmega128 design to the ATxmega128a1 platform. Target hardware is Atmel's Xplained development board, new one, just purchased this month. Have access to standards in a metrology/calibration lab. Using a HP 5335A Universal counter and a Tek DPO4054 to validate code. Both are reporting same results. Per the Bascom's help file(config tc) I setup the timer for a 400mS rate. Per the equation, all makes sense, normal timer calculations. What the actual result is with the TcD0_per = 50000 is 393.7mS not 400mS. With a 8uS tick I would assume this to be closer to 400mS than it is. With TcD0_per = 50782 the result is 399.9mS. In this example the interrupt priority is hi, makes no difference from lo, just was trying different settings. Code is below. What am I missing? Is there a better method to test the timer rates? My final target will be a 10mS tick. Just trying to keep the code baseline to the help file. Any help would be appreciated. TIA. [code:1:4a00d910f7] $regfile = "xm128a1def.dat" $hwstack = 100 ' over ride default of 32 for the hardware stack $swstack = 100 ' over ride default of 8 for the SW stack $framesize = 100 ' over ride default of 24 for the frame space $crystal = 32000000 ' Xplained Xtal $baud = 115200 ' USB comm port(COM1:) $xramsize = &H800000 ' Xplained xram '=====[ Setup System Clock ]=================================================== Config Osc = Enabled , 32mhzosc = Enabled Config Sysclock = 32mhz, Prescalea = 1 , Prescalebc = 1_1 '--> 32MHz Disable Interrupts '=====[ Output Timer ISR for Oscilloscope Check on Portd.0 ]================== Config PortD.0 = Output 'GPIO.0 J3, measure the tick pulse on scope / counter 'Timer D0 Config TcD0 = Normal , Prescale = 256 TcD0_per = 50000 '32MHz/256 = 125KHZ(8uS) = 400mS per help file CONFIG TCXX, actual measured is 393.7mS 'TcD0_per = 50782 '32MHz/256 = 125KHZ(8uS) = adjusted value to get 399.9mS On TcD0_ovf TcD0_ISR 'Setup overflow interrupt Enable TcD0_ovf , hi 'Enable overflow interrupt in LOW Priority Config Priority = Static , Vector = Application , hi = Enabled Enable Interrupts '****************************************************************************** '*****[ Start of main loop ]*************************************************** '****************************************************************************** Main: Do !nop Loop '------------------------------------------------------------------------------ '=====[ Timer ISR routine ]==================================================== TcD0_ISR: Toggle PortD.0 'GPIO.0, scope / counter trigger Return '------------------------------------------------------------------------------[/code:1:4a00d910f7] [b:4a00d910f7][color=red:4a00d910f7](BASCOM-AVR version : 2.0.7.6 )[/b:4a00d910f7][/color:4a00d910f7]

Viewing all articles
Browse latest Browse all 20867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>