Makes a pulse at PB4 and is 2 minutes on and 28 minutes off. Power can be tuned off by the raising flag at INT0 (PB1). Power consumption is at ~0.3mA
Last active
January 15, 2020 11:45
-
-
Save mcenderdragon/6931ce6ea47e0d66e6cdf4f1b2c24591 to your computer and use it in GitHub Desktop.
A LED blinker based on a ATTiny13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'the BASIC file / from bascom | |
$Regfile="attiny13.dat" | |
$Crystal=1200000 | |
'$hwstack = 64 | |
'$swstack = 64 | |
'$framesize = 8 | |
'attiny13 is delivered with internal clock of 9.6Mhz | |
'initial system clock prescaling of 8. | |
' 9.6 / 8 = 1.2Mhz ? | |
Config Timer0 = Timer , Prescale = 64 ' 1.200.000/64 = 18750 | |
Config INT0 = FALLING 'PB1 | |
On Timer0 Tim0_isr | |
On Int0 Int0_isr | |
Dim time_count as DWord | |
Dim stop_count as Byte | |
Config Portb.0 = Input | |
Set Portb.0 | |
Config Portb.1 = Input | |
ReSet Portb.1 | |
Config Portb.2 = Input | |
Set Portb.2 | |
Config Portb.3 = Input | |
Set Portb.3 | |
Config Portb.4 = Input | |
Set Portb.4 | |
Config Portb.5 = Input | |
Config PORTB.4 = OUTPUT | |
time_count = 0 | |
Didr0 = Bits(ain1d , Ain0d) ' Disable digital input buffer on the AIN1/0 pin | |
Reset Acsr.acbg ' Disable Analog Comparator Bandgap Select | |
Stop ADC 'We want to reduce power consumption | |
Stop Ac | |
Stop Watchdog | |
Enable Int0 | |
Enable Timer0 | |
Enable Interrupts | |
do | |
'main programm | |
Enable Int0 | |
Enable Timer0 | |
Enable Interrupts | |
waitms 2 | |
Config Powermode = idle | |
loop | |
End | |
'the following code is executed when the timer rolls over | |
Tim0_isr: 'should be executed with 75Hz | |
TImer0 = 6 '256-250 = 6; 18750/250 = 75 | |
if time_count > 175500 then '75 * 30 * 60 = 175500; so 30 minutes | |
time_count = -1 | |
elseif time_count = 0 then | |
PORTB.4 = 1 | |
elseif time_count = 9000 then '75*60*2 = 9000; so 2 minutes | |
PORTb.4 = 0 | |
endif | |
if stop_count > 1 then | |
decr stop_count | |
elseif stop_count = 1 then | |
decr stop_count | |
PORTb.4 = 0 | |
endif | |
'toggle PORTb.4 | |
incr time_count | |
Return | |
Int0_isr: | |
stop_count = 75 | |
Return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:1000000009C0F3C0189562C01895189518951895F1 | |
:10001000189518958FE98DBFC0EAE8EB4E2EDD27C5 | |
:100020005D2EA89584B7082E877F84BF88E1992725 | |
:1000300081BD91BDEEE3F0E0A0E6B0E088278D93AE | |
:100040003197E9F7662483E083BF80E08FBD85B7F1 | |
:100050008C7F826085BFB898C09AB998C198BA98C9 | |
:10006000C29ABB98C39ABC98C49ABD98BC9A00E047 | |
:1000700010E020E030E0A0E60D931D932D933C931B | |
:1000800083E084BB46983798479A9FB7F89481B528 | |
:10009000886181BD877E81BD9FBF7BB770647BBF58 | |
:1000A00079B7726079BF78947BB770647BBF79B79A | |
:1000B000726079BF789482E090E0E7D075B7777C82 | |
:1000C000706275BF8895F0CFF894FFCF0F921F92A2 | |
:1000D0002F923F924F925F927F92AF92BF920F9377 | |
:1000E0001F932F933F934F935F936F937F938F93C0 | |
:1000F0009F93AF93BF93CF93DF93EF93FF938FB70C | |
:100100008F9376E072BF4CE85DEA62E070E0A0E6B3 | |
:100110000D911D912D913C91041715072607370766 | |
:1001200010F009F001C00AC00FEF1FEF2FEF3FEFF3 | |
:10013000A0E60D931D932D933C9321C040E050E029 | |
:1001400060E070E0A0E60D911D912D913C910417A7 | |
:1001500015072607370709F002C0C49A10C048E205 | |
:1001600053E260E070E0A0E60D911D912D913C916D | |
:10017000041715072607370709F001C0C498009136 | |
:100180006400013010F009F001C006C080916400E5 | |
:100190008150809364000BC000916400013009F02D | |
:1001A00006C080916400815080936400C498A0E6EA | |
:1001B00056D08F918FBFFF91EF91DF91CF91BF917B | |
:1001C000AF919F918F917F916F915F914F913F91EF | |
:1001D0002F911F910F91BF90AF907F905F904F90A4 | |
:1001E0003F902F901F900F9018950F921F922F9273 | |
:1001F0003F924F925F927F92AF92BF920F931F9365 | |
:100200002F933F934F935F936F937F938F939F931E | |
:10021000AF93BF93CF93DF93EF93FF938FB78F93FA | |
:100220008BE4809364008F918FBFFF91EF91DF91FA | |
:10023000CF91BF91AF919F918F917F916F915F917E | |
:100240004F913F912F911F910F91BF90AF907F9051 | |
:100250005F904F903F902F901F900F9018950D91A9 | |
:100260001D912D913C910F5F1F4F2F4F3F4F3C939E | |
:100270002E931E930E9308953197F1F70895689485 | |
:1002800062F80895E89462F80895EF93FF93EE27DB | |
:10029000E82BE92B31F0ECE2F1E03197F1F701972F | |
:0802A000D1F7FF91EF910895E1 | |
:00000001FF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment