'*******************************************************************************
'Name : DAC_TEST.bas
'Compiler 2.0.7.7
'
'Cpu : xMega32a4
'crystal : 8Mhz external
'
' fuses selection
'
' - userid = 0xFF
' - WDWP = 8 cycles (8ms @ 3.3V)
' - WDP = 8 cycles (8ms @ 3.3V)
' - DVSDON = unchecked
' - BOOTRST = application
' - BODPD = BOD enables continuosly
' - RSTDISBL = unchecked
' - SUT = 0 ms
' - WDLOCK = unchecked
' - BODACT = BOD enables continuosly
' - EESAVE = unchecked
' - BODLVL = 2.4V
'
' Versie 1001
' - Eerste release
'
'*******************************************************************************
$regfile = "xm32a4def.dat"
$crystal = 8000000 '8MHz
$hwstack = 250
$swstack = 120
$framesize = 120
Config Submode = New
'*******************************************************************************
' Config i/o
'*******************************************************************************
Config Porta.5 = Output
Config Portb.0 = Input
Config Portb.1 = Output
Config Portc.0 = Output
Config Portc.1 = Input
Config Portc.2 = Input
Config Portc.3 = Input
Config Portc.4 = Output
Config Portc.5 = Input
Config Portc.6 = Input
Config Portc.7 = Output
Config Portd.0 = Input
Config Portd.1 = Input
Config Portd.2 = Input
Config Portd.3 = Input
Config Portd.4 = Output
Config Portd.6 = Input
Config Portd.7 = Output
Config Porte.0 = Output
Config Porte.2 = Output
Config Porte.3 = Output
'*******************************************************************************
' Config Clock
' Enable the external oscillator with Range 2MHz....9MHz
'*******************************************************************************
Config Osc = Disabled , Extosc = Enabled , Range = 2mhz_9mhz , Startup = Xtal_256clk
Config Sysclock = External , Prescalea = 1 , Prescalebc = 1_1
Portcfg_clkevout = 10 'output sysclk clock on PortD.7
'*******************************************************************************
' Config DAC
'*******************************************************************************
Config Dacb = Enabled , Io0 = Enabled , Io1 = Enabled , Channel = Dual , Reference = Avcc , Interval = 64 , Refresh = 64
Dacb0 = 0
Dacb1 = 0
'*******************************************************************************
' Config timer 0 al 100mSec ticker
'*******************************************************************************
Config Tcc0 = Normal , Prescale = 256
Tcc0_per = 3125
On Tcc0_ovf Tc0_isr
Enable Tcc0_ovf , Lo
'*******************************************************************************
' Declare Alias
'*******************************************************************************
Zenderled Alias Porte.0
Power_on Alias Porte.3
'*******************************************************************************
' Declare Variable
'*******************************************************************************
Dim 100ms_flag As Bit
Dim Seconde As Byte
Dim Seconde_flag As Bit
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled 'Enable Lo Level Interrupts
'*******************************************************************************
' Interrupts
'*******************************************************************************
Enable Interrupts
'*******************************************************************************
' default settings
'*******************************************************************************
Reset Zenderled 'default led on
'*******************************************************************************
' main program
'*******************************************************************************
Wait 1
Power_on = 1
Dacb1 = 3000
Dacb0 = 3000
Do
Loop
End
'*******************************************************************************
' Timer 0 isr routine
'*******************************************************************************
Tc0_isr:
Set 100ms_flag
Return
|