User Tools

Site Tools


avr_assembler

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
avr_assembler [2009/07/27 02:08]
macegr
avr_assembler [2009/07/27 02:32]
macegr
Line 1: Line 1:
-Renesis from Darker Technologies contributes his AVR assembly code example for controlling ShiftBrites using an Atmega164:+Renesis from [[http://darkertechnologies.com/notes/|Darker Technologies]] contributes his AVR assembly code example for controlling ShiftBrites using an Atmega164:
  
-**main.asm** +**shiftbrite_example_20090726.asm** 
-<code asm> +<code asm>;//_ shiftbrite_example_20090726.asm 
-;//_ part definition and include files+
 +; avr assembly macros for driving shiftbrites. 
 +
 +; this example swaps the colors purple and green between two  
 +; shiftbrites a few times a second at 8MHz core speed.  
 +
 +; the number of shiftbrites and the io pins used by the code are  
 +; defined in the file "sb_config.inc". 8bit and 10bit color data  
 +; modes can also be selected in this file. 
 +
 +; The color data is stored in sram and shifted out by the 
 +; macro "sb_send_all". The cache size is dependent on the number 
 +; of shiftbrites and 8b or 10b mode selection. Data can be created 
 +; in, stored to, or loaded from the cache using the macros "sb_sti", 
 +; "sb_st", and "sb_ld"
 +
 +; detailed descriptions of these macros can be found in the file 
 +; "sb_frontend.inc"
 +
 +; developed on avrstudio4 using conditional preprocessor directives. 
 + 
 + 
 +;//_ part definition (change this to match your avr)
  
 .include "m164pdef.inc" .include "m164pdef.inc"
 +
 +
 +;//_ shiftbrite related include files
 +
 .include "sb_config.inc" .include "sb_config.inc"
 .include "sb_backend.inc" .include "sb_backend.inc"
 .include "sb_frontend.inc" .include "sb_frontend.inc"
 +
  
 ;//_ register definitions ;//_ register definitions
Line 18: Line 45:
 .def temp5  = r20 .def temp5  = r20
 .def temp6  = r21 .def temp6  = r21
 +
  
 ;//_ initialization ;//_ initialization
Line 34: Line 62:
     sb_pin_init     sb_pin_init
          
-    ; setup shiftbriter color data +    ; setup shiftbrite red/green/blue color data
- +
-    sb_sti 1,$aa,$00,$00 +
-    sb_sti 2,$00,$ff,$aa+
  
 +    sb_sti 1,$ff,$00,$ff
 +    sb_sti 2,$00,$ff,$00
  
  
Line 44: Line 71:
  
 deathloop:  deathloop: 
 +
 +    ; shift color data out 
  
     sb_send_all     sb_send_all
  
-    ;primitive delay routine+    ; primitive delay routine
  
     ldi r16,100     ldi r16,100
Line 70: Line 99:
     sb_st 2,r1,r2,r3     sb_st 2,r1,r2,r3
  
-    ;restart mainloop+    ; restart mainloop
  
     jmp deathloop     jmp deathloop
Line 90: Line 119:
  
     ; data pin         ; data pin    
-.set sb_d_port   portc +.set sb_d_port   porta 
-.set sb_d_ddr    = ddrc +.set sb_d_ddr    = ddra 
-.set sb_d_pin    = pc0+.set sb_d_pin    = pa0
  
     ; latch pin     ; latch pin
-.set sb_l_port   portc +.set sb_l_port   porta 
-.set sb_l_ddr    = ddrc +.set sb_l_ddr    = ddra 
-.set sb_l_pin    = pc1+.set sb_l_pin    = pa1
  
     ; enable pin     ; enable pin
-.set sb_e_port   portc +.set sb_e_port   porta 
-.set sb_e_ddr    = ddrc +.set sb_e_ddr    = ddra 
-.set sb_e_pin    = pc2+.set sb_e_pin    = pa2
  
     ; clock pin     ; clock pin
-.set sb_c_port   portc +.set sb_c_port   porta 
-.set sb_c_ddr    = ddrc +.set sb_c_ddr    = ddra 
-.set sb_c_pin    = pc3+.set sb_c_pin    = pa3
 </code> </code>
  
Line 538: Line 567:
     ;     ;
     ; 10b example:  sb_st 1,r16,r17,r18,r19,r20,r21     ; 10b example:  sb_st 1,r16,r17,r18,r19,r20,r21
-    ; 8b example:   sb_st 1,r16.r18,r20+    ; 8b example:   sb_st 1,r16,r18,r20
  
 #if (SB8_MODE) #if (SB8_MODE)
/home/macetec/public_html/docs/data/pages/avr_assembler.txt · Last modified: 2009/07/27 02:32 by macegr