prjbrook

MacroExperimentI.asm

Aug 10th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. ;three counters r17,r18,r19 loop 256*256*9 * 484uS = about 1 second at 1.6MHz
  2. ;used: avrasm2 -fI -l list.lst TinyFlashA.asm
  3. ;and for another file used: avrdude -p ATtiny15 -c usbasp -U flash:w:blinker15_B.hex:i
  4. ;output via LED 8 bit sequence eg r0 = $0F. Looked good on LED. Running human slow so I can see what's happening.
  5. ;1/8/19. Put Macros intoseparate txt file that gets included.
  6. ;Wed Aug 7 10:54:36 NZST 2019 Wored OK. Just too long for lead tone and between bytes.
  7. ;Thu Aug 8 09:47:52 NZST 2019 Longintro needs to have constant length. Also need ti think about use/non use of stop bits...
  8. .include "tn15def.inc"
  9. .include "t15MACROS_C.txt"
  10.  
  11. .ESEG eevar1: .DW 0x0123 ; initialize 1 word in EEPROM Doesn't burn into eeprom
  12. ;Had to use C:\Users\Dell\Desktop\Setup Files\AVR_assembler_avrasm2>avrdude -p ATtiny15 -c usbasp -U flash:w:MacroExperimentC.hex:i -U eeprom:w:eeprom5.raw:r
  13. .CSEG
  14.  
  15. .LISTMAC
  16. start:
  17. ldi r16,$ff
  18. out DDRB,r16
  19.  
  20. ldi r16,32 //**new read 16 eeprom bytes
  21. mov eepromLimit, r16 ;counter fro number of eeprom bytes to output
  22. exp1: ;start long tone here
  23. ldi r16,$fe ;random. Just for testing
  24. mov r0,r16 ;so we can bit-bang r0 with below.
  25. clr r1 ;start at eemrom adr 0
  26. pinDown ;new intro pulls pin down then up for clearer level to Arduino
  27. longIntro
  28. pinUp
  29. longIntro ;send long tone to start things off
  30.  
  31. doSerial: ;serially output bits that are in r0
  32. wait3 ;gap between each byte
  33. getEepromByte r1,r0
  34. ldi r16,$08 ;for 8 bits
  35. mov r2,r16 ;so r2 is our bit counter
  36.  
  37. doBit: ;cycle from here 8 times to get all bits out of r0 thru carry.
  38. pinDown
  39. wait3
  40. pinUp
  41. delay1
  42. rol r0 ;send LH bit into carry
  43. brcs down ;is it a one
  44. pinDown ;if here, must have been a zero in carry. So drop pin to lowy
  45. down:
  46. delay1 ;with pin up or down. Key step in this prog
  47. pinUp ;maybe already up. Check for jitter.
  48. delay1 ;finish off frame
  49. delay1 ;just a stop bit. Necessary? ** This stop bit occurs each bit. Needed?
  50. dec r2 ;counter reached zero yet (from 8)
  51. breq nextByte ;if we've reached 0, all 8 bits are gone. Get out.
  52.  
  53. rjmp doBit ;couldn't use branches, eg brne doBit as it's too far.
  54. nextByte:
  55. inc r1 ;bump eeprom adr
  56. // **Maybe put in a stop bit here.
  57. cp r1,eepromLimit ;got to limit of eeprom bytes required?
  58. breq endL ;if yes get out
  59. rjmp doSerial
  60.  
  61. // rjmp exp1 ;**take out later
  62. //getEepromByte r1,r0
  63.  
  64. endL: rjmp endL
Advertisement
Add Comment
Please, Sign In to add comment