;This program displays 07 on the seven segments. ;Connect the 7-segment module to the upper pins of JA and JB. ;The code is in AVR assembly. Use AVR Studio IDE 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 ;JA (PORTA) and JB(PORTC) as outputs LDI R20, 0xFF OUT DDRA, R20 OUT DDRC, R20 L1: LDI R20, 0x07 ;R20 = 0x07 (to display '7' on 7-segment we should put 0x07 on the port) ;=========================== ;Right 7-segment ;=========================== ;put the high nibble of R20 on JB (PORTC) MOV R16, R20 ;R16 = R20 ANDI R16, 0x70 SWAP R16 OUT PORTC, R16 ;put the low nibble of R20 on JA (PORTA) MOV R16, R20 ;R16 = R20 ANDI R16, 0x0F ;R16 = R16 & 0x0F OUT PORTA, R16 ;PORTA = R16 CALL DELAY ;wait for a while ;R20 = 0x3F (to display '0' on 7-segment we should put 0x07 on the port) LDI R20, 0x3F ;=========================== ;Left 7-segment ;=========================== ;put the high nibble of R20 on JB (PORTC) MOV R16, R20 ;R16 = R20 ANDI R16, 0x70 ORI R16, 0x80 ;enable the catode for the Left 7-segment SWAP R16 OUT PORTC, R16 ;put the low nibble of R20 on JA (PORTA) MOV R16, R20 ANDI R16, 0x0F OUT PORTA, R16 CALL DELAY ;wait for a while RJMP L1 ;goto L1 ;======================================== ;The delay subroutine makes a small delay ;======================================== DELAY: LDI R16, 0 ;R16 = 0 DL1: NOP DEC R16 ;R16 = R16 - 1 BRNE DL1 ;if R16 is not zero go to DL1 RET