MyTetra Share
Делитесь знаниями!
main.asm
Время создания: 08.12.2017 21:41
Раздел: Electronics - Microcontrollers - AVR8 - AVR ASM - ASM_PROJ - DS18B20 - DS18B20 v.4

;.include "m8adef.inc"

.include "m1281def.inc"


.include "macro.inc"


;INTERRUPT VECTORS

rjmp reset ;ïðåðûâàíèå îò RESET, ññûëàåìñÿ íà îáðàáîò÷èê ïðåðûâàíèÿ - initial

; rjmp 0 ;rjmp service_INT0 ;âíåøíåå ïðåðûâàíèå 0

; rjmp 0 ;rjmp service_INT1 ;âíåøíåå ïðåðûâàíèå 1

; rjmp 0 ;rjmp service_OC2 ;ñîâïàäåíèå TCNT2 è OCR2

; rjmp 0 ;rjmp service_OVF2 ;ïåðåïîëíåíèå TCNT2

; rjmp 0 ;rjmp service_ICP1 ;çàõâàò â ICP1

; rjmp 0 ;rjmp service_OC1A ;ñîâïàäåíèå TCNT1 è OCR1A

; rjmp 0 ;rjmp service_OC1B ;ñîâïàäåíèå TCNT1 è OCR1B

; rjmp 0 ;rjmp service_OVF1 ;ïåðåïîëíåíèå TCNT1

; rjmp 0 ;rjmp service_OVF0 ;ïåðåïîëíåíèå TCNT0

; rjmp 0 ;rjmp service_SPI ;ïðåðûâàíèå îò ìîäóëÿ SPI

; rjmp 0 ;rjmp service_URXC ;ïîëó÷åíèå áàéòà ïî USART

; rjmp 0 ;rjmp service_UDRE ;îïóñòîøåíèå UDR â USART

; rjmp 0 ;rjmp service_UTXC ;ïåðåäà÷à áàéòà ïî USART

; rjmp 0 ;rjmp service_ADCC ;ïðåðûâàíèå îò ÀÖÏ

; rjmp 0 ;rjmp service_ERDY ;çàâåðøåíèå çàïèñè â EEPROM

; rjmp 0 ;rjmp service_ACI ;ïðåðûâàíèå îò êîìïàðàòîðà

; rjmp 0 ;rjmp service_TWI ;ïðåðûâàíèå îò ìîäóëÿ TWI

; rjmp 0 ;rjmp service_SPMR ;çàâåðøåíèå âûïîëíåíèÿ spm




.include "memory.asm"


.cseg

.org 0x20


;STACK INITIALISATION

reset:

ldi R16,low(RAMEND)

out SPL,R16

ldi R17,high(RAMEND)

out SPH,R17


;DEFINES

#define SEGM_DDR DDRC

#define SEGM PORTC //PC1..PC4 - 1..4 segment cathodes

#define CATHODE_MASK 0xE1 //1110.0001 - mask for turning off pins [1..4]



.equ SENSOR_DDR = DDRD

.equ SENSOR_PORT = PORTD

.equ SENSOR_PIN = PIND

.equ SENSOR = 0

.equ SENSOR_MASK = 0x01


;Commands for temperature sensor:

.set SEN_NOID = 0xCC ; skip identification

.set SEN_CONVERT = 0x44 ; convert temperature to HEX

.set SEN_READ_DAT = 0xBE ; send all data to master


;PERIPHERY INITIALISATION

SBI SENSOR_DDR, SENSOR

CBI SENSOR_PORT,SENSOR


;MAIN PROGRAM

main:

CALL sensor_get_data

LDS R16, var_temperature

CALL convert_HEX_to_DEC ; R23 - hundreds; R24 - decimals; R25 - units


//------

// show temperature

// convert temper to code for indicator


;segment #1 (SIGN)

LDS R22, var_temperature

SBRS R22, 7 ; skip next if bit 7 is set

CALL main_skip_segm1 ; go here if there is no sign


SBI SEGM, 1

LDI R22, 0x40 ; sign of minus

CALL indicator_send_data

CBI SEGM, 1


main_skip_segm1:

;segment #2 (HUNDREDS)

MOV R22, R23

CALL indicator_get_code

MOV R23, R22

SBI SEGM, 2

CALL indicator_send_data

CBI SEGM, 2


;segment #3 (DECIMALS)

MOV R22, R24

CALL indicator_get_code

MOV R24, R22

SBI SEGM, 3

CALL indicator_send_data

CBI SEGM, 3


;segment #4 (UNITS)

MOV R22, R25

CALL indicator_get_code

MOV R25, R22

SBI SEGM, 4

CALL indicator_send_data

CBI SEGM, 4


// show data


//------

rjmp main

#include "sensor_ds18b20.asm"

#include "indicator.asm"

#include "math.asm"


Так же в этом разделе:
 
MyTetra Share v.0.53
Яндекс индекс цитирования