Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ATtiny2313 code help

Status
Not open for further replies.

NASR12

New Member
HI ALL

anyone use avrs i found some code that does What Written this programe.


thanks in advance..

---------------------------

AvrStudio
-----------

include "m88def.inc" ; Processor
definitions
.include "system_macros.inc" ; Register allocation, processor specific
.include "rom_table_init_simple.gen" ; Created automatically
.include "stepper_cfg_simple.inc" ; Configuration for specific motor
.include "pin_macros.inc" ; I/O definitions
.include "bridge_macros.inc" ; Bridge control
.include "curr_reduction.inc" ; Current reduction
.include "decay_macros.inc" ; Decay control algorithms
.include "table_macros.inc" ; ROM & RAM table processing
.include "da_macros.inc" ; D/A converter support



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;************************ Initialization ****************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;** Watchdog initialization

; WATCHDOG_INIT_SLOW

;** Stack initialization

STACK_INIT

;** I/O initilization

CONFIGURE_IO_PORTS
BRIDGE_A_DISABLE_FAST
BRIDGE_B_DISABLE_FAST

;** SPI initialization

SPI_INITIALIZE

;** Timer initialization for idle timeout

CURR_REDUCTION_INIT
CLEAR_CURR_REDUCTION_TIMEOUT

;** Initialize step configuration

ROM_TABLE_INIT

;** Initialize decay control

CMP_DECAY_INIT
CMP_DECAY_PREPARE_NEXT

;** Change watchdog timeout from init mode to operational mode

; WATCHDOG_INIT_FAST

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; *************** Microstep common control loop ********************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

main_loop:

wdr

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 'Enable' signal processing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CHECK_ENABLE
cpi temp,0
brne enable_is_high

enable_is_low:
; check for change from 'enable' to 'disable'
clr temp
cp ENABLE_MODE,temp
breq main_loop
; Ok, this is a change from 'enable' to 'disable'
; We need to disable bridge control
; and setup D/A converter to 'adjust' mode
BRIDGE_A_DISABLE_FAST
BRIDGE_B_DISABLE_FAST
SPI_TRANSFER_ADJUST

rjmp main_loop

enable_is_high:
; check for change from 'disable' to 'enable'
clr temp
cp ENABLE_MODE,temp
brne enable_continue

; Ok, this is a change from 'disable' to 'enable'
; We need to update D/A converter (from 'adjust' mode )
; and reenable bridges

SPI_TRANSFER
BRIDGE_A_ENABLE
BRIDGE_B_ENABLE
inc ENABLE_MODE

enable_continue:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Check if current reduction should be applied
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CHECK_CURR_REDUCTION
cpi temp,0
breq no_current_reduction
SPI_TRANSFER ; execute current reduction

no_current_reduction:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Process comparator inputs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CMP_DECAY_CHECK_A
CMP_DECAY_CHECK_B

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Check if next step should be executed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CHECK_STEP
cpi temp,0
brne step_to_make

rjmp main_loop; no next step (to large distance for relative branch)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;******************* Step initialization *************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

step_to_make:

CLEAR_CURR_REDUCTION_TIMEOUT

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Next step should be executed - load new step data

ROM_TABLE_STEP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Execute transfer to D/A converter

SPI_TRANSFER

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Execute new bridge control

BRIDGE_A_ENABLE
BRIDGE_B_ENABLE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Prepare new decay control

CMP_DECAY_PREPARE_NEXT

rjmp main_loop


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ********************* ROM step tables ******************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


#include "rom_table_data_simple.gen" ; Created automatically
; in externl tool


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ********************* RAM step tables ******************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


.dseg

sinus_table_step:
.byte (STEP_NUMBER * 2)
sinus_table_step_half:
.byte (STEP_NUMBER * 2)
sinus_table_step_end:

decay_table:
.byte (STEP_NUMBER * 4)
decay_table_end:
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top