Hello guys,
anyone know how do I do this
' --------[ Device Config]----------------------------------------------------
$regfile = "m8def.dat"
$crystal = 16000000
$baud = 19200
' --------[ Variable Config ]-------------------------------------------------
Dim Voltage As Word
Dim Currentsum As Word
Dim Current1 As Word
Dim Current2 As Word
' --------[ Costant Config ]--------------------------------------------------
Const Cut_volt = 9000
' --------[ General Port Config ]---------------------------------------------
Config Portd.4 = Output
' Kill switch enable
Config Portb.1 = Output
' Buzzer circuit
' --------[ Timer Config ]----------------------------------------------------
' Timer1 Register A
Tccr1a = &B00000000
' Normal Port Operation
' Timer1 Register B
Tccr1b = &B00001011
' Timer set to CTC mode
' Prescaler at 64
' ORC1A
Compare1a = 100
' Produces a 1237,62Hz frequncy
' for the buzzer
' --------[ ADC config ]------------------------------------------------------
' ADC status register
Adcsra = &B11000111
' ADC started
' First Convertion also started
' Cause we have a 16MHz clock
' we setted the prescaler to
' 128 so the ADC clock is < 200KHz
Admux = &B00000000
' External reference is applied
' Convertion data are shown right wise
' ADC channel setted to 0, but this
' is just done for setting the ADMUX register
' changes in the process
' --------[ Initialize ]------------------------------------------------------
Portb.1 = 1
' Turn off the buzzer circuit to save energy
Portd.4 = 0
' The Kill switch is off, letting the button here terminates start up
Wait 1
' Wait some time, so the user is aware that he turns on the circuit
' and no brown out reset turns the circuit back on
Tccr1a = &B01000000
' Send some oscilations to the buzzer
Waitms 200
' for some time
Tccr1a = &B00000000
' then cut the buzzer and
Portd.4 = 1
' enable the supply permenately
Voltage = 0
' Set the variable
Voltage = Getadc(0)
' Start a convertion and get the voltage
Voltage = Voltage * 13
Voltage = Voltage + 100
' Do the math so the numbers are familiar with
' human being
' Check voltage
If Voltage < Cut_volt Then
' if the voltage is lower than acceptable ( 9V0 )
' then
Tccr1a = &B01000000
Waitms 100
Tccr1a = &B00000000
Waitms 100
Tccr1a = &B01000000
Waitms 100
Tccr1a = &B00000000
Waitms 100
' warn the user and
Portd.4 = 0
' kill the circuit to save the battery
End If
' --------[ Main ]------------------------------------------------------------
Main:
Do
Voltage = Getadc(0)
' Start a convertion and get the voltage
Voltage = Voltage * 13
If Voltage <> 0 Then
Voltage = Voltage + 100
End If
' Do the math so the numbers are familiar with
' human being
Print Voltage ; " " ; Chr(13);
' Send data to UART
Loop Until Voltage < Cut_volt
' if the condition is bridged then
Tccr1a = &B01000000
Waitms 100
Tccr1a = &B00000000
Waitms 100
Tccr1a = &B01000000
Waitms 100
Tccr1a = &B00000000
Wait 5
' warn the user and
Portd.4 = 0
' kill the circuit to save the battery
End
And Hey Admin!!! Still.... nothing on that tutorial... it doesn't show up at the tutorial page... So I might need your help....