;Cerebot2 has 8 ports named as JA, JB, JC,...,and JH respectively. Cerebot2 also has four LEDs named as LD1, LD2, LD3, and LD4. ;This program toggles JA (portA), JB (port C), and the four LEDs. ;This code is for AVR Studio IDE. Use AVR Studio to make the hex file. ;For more information see www.microdigitaled.com and www.digilentinc.com .INCLUDE "M64DEF.INC" ;ATmega64 is used by Cerebot2 board ;initialize SP (Stack Pointer) LDI R20, HIGH(RAMEND) OUT SPH, R20 LDI R20, LOW(RAMEND) OUT SPL, R20 LDI R20, 0xFF OUT DDRA, R20 ;JA as output OUT DDRC, R20 ;JB as output OUT DDRE, R20 ;user LED as output L1: LDI R20, 0xAA ;R20 = 1010 1010 B OUT PORTA, R20 OUT PORTC, R20 OUT PORTE, R20 RCALL DELAY ;wait 1 second LDI R20, 0x55 ;R20 = 0101 0101 B OUT PORTA, R20 OUT PORTC, R20 OUT PORTE, R20 RCALL DELAY ;wait 1 second RJMP L1 ;======================================================================= ;The Delay subroutine creates a delay which is 1 second for XTAL = 8MHz. ;======================================================================= DELAY: LDI R21, 32 ;R21 = 32 DL1:LDI R22, 200 ;R22 = 200 DL2:LDI R23, 250 ;R23 = 250 DL3:NOP NOP DEC R23 ;R23 = R23 - 1 BRNE DL3 ;if R23 is not equal to zero then go to DL3 DEC R22 ;R22 = R22 - 1 BRNE DL2 ;if R22 is not equal to zero then go to DL2 DEC R21 ;R21 = R21 - 1 BRNE DL1 ;if R21 is not equal to zero then go to DL1 RET