Last active
October 26, 2020 19:48
-
-
Save J4e8a16n/76348023c1dbfac21b0947abe43be87d to your computer and use it in GitHub Desktop.
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
main: | |
; Load stack register in two steps (4 commands) Note: When you are loading a | |
LDI R16, HIGH(RAMEND) ; load UPPER byte 1-byte register from a 2-byte word, first | |
OUT SPH,R16 ; to stack pointer you load either the HIGH([word]) | |
LDI R16,LOW(RAMEND) ; Lower byte or the LOW([word]), second | |
OUT SPL,R16 ; to stack pointer ;OUT SPL,R16 writes R16 to SPL. | |
; Define directions for port pins | |
ldi r16,(1<<PB0)|(1<<PB1)|(1<<PB2)|(1<<PB3)|(1<<PB4) ;load to R16 all ports set to output 0001 1111 | |
out DDRB,R16 ; set direction . OUT DDRB,R16 writes R16 to DDRB. 0x1F=31 | |
ldi R16,(1<<CS01) ; CS01 = 1 in def clock counter with I/O clock/8 and WGM2 live in TCCR0B | |
out TCCR0B,R16 | |
; = One (1) shifted by 0 bit = 1 | |
ldi R16,(1<<WGM01) ; WGM01 = 1 in def table ;WGM[2:0] = 0x2 sets CTC mode.Clear Timer on Compare Match (CTC) mode; COM0cn =0 | do not control pins with compare match. | |
out TCCR0A,R16 ;WGM1/WGM0 live in TCCR0A | |
ldi R16,(1<<OCIE0A) ; OCIE0A = 4 in def Output Compare_0 interrupt enable take a 1 and shif it by 4 (bit4 in TIMSK ) | |
out TIMSK,R16 ;put in the timsk register OCIE0A = 4 in tne at85def.inc file | |
ldi R16,125 | |
out OCR0A,R16 ; OCR0A = 125 = 1ms = 125/125000Hz | |
sei ; set enable interrupt on the chip globally | |
loop: | |
rjmp loop ; when TCNT0 = 7D out |2 clock cycles every F11 * 4 times /= 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment