Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////
  2. // Laboratory AVR Microcontrollers Part1
  3. // Program template for lab 7
  4. // Authors:
  5. //
  6. // Group:
  7. // Section:
  8. //
  9. // Task:
  10. //
  11. // Todo:
  12. //
  13. //
  14. // Version: 3.0
  15. ;//////////////////////////////////////////////////////////////////////////////
  16. #include <avr/io.h>
  17. #include <avr/interrupt.h>
  18. #include <avr/pgmspace.h>
  19.  
  20. #define nLength 100
  21.  
  22. const uint8_t const TAB_ROM[] PROGMEM = {0x44, 0xFF, 0x00, 0x44, 0xAA, 0x00, 0xFF, 0xFF};
  23. uint8_t TAB_RAM[nLength];
  24.  
  25. //---------------------------------------------------------------------
  26. int main (void)
  27. {
  28. DDRA = 0x00;
  29. DDRB = 0xFF;
  30. PORTA = 0x00;
  31. PORTB = 0xFF;
  32. //int i=0;
  33. //iterator
  34.  
  35.  
  36. while (PINA==0xFF)
  37. {
  38. }
  39. const uint8_t const* address = pgm_get_far_address(TAB_ROM[0]);
  40. while ( pgm_read_byte_far(address)!=0xFF || pgm_read_byte_far(address+1)!=0xFF)
  41. {
  42. PORTB=pgm_read_byte_far(address);
  43. address++;
  44. }
  45.  
  46. //---------------------------------------------------------------------
  47. // Main program code place here
  48. // 1. Place here code related to initialization of ports and interrupts
  49. // for instance:
  50. // port A as output and initial value 0
  51. // DDRA=0xFF
  52. // PORTA=0x00
  53. // port B as input and initial value FF
  54. // DDRB=0x00
  55. // PORTA=0xFF
  56.  
  57. // 2. Enable interrupts if needed
  58. // sei();
  59.  
  60. // 3. Place here main code
  61.  
  62.  
  63. //----------------------------------------------------------------------
  64. // Program end
  65. //----------------------------------------------------------------------
  66. }
  67. // -------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement