Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 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 = {0x01,0x02,0x03,0x04,0x05, 0x00, 0x00 };
  23. uint8_t TAB_RAM[nLength];
  24.  
  25.  
  26. //---------------------------------------------------------------------
  27. int main (void)
  28. {
  29.     //---------------------------------------------------------------------
  30.     // Main program code place here
  31.     // 1. Place here code related to initialization of ports and interrupts
  32.     // for instance:
  33.     //    port A as output and initial value 0
  34.      DDRA=0xFF;
  35.      PORTA=0x00;
  36.     //    port B as input and initial value FF
  37.      DDRB=0x00;
  38.     PORTB=0xFF;
  39.  
  40.    
  41.     // 2. Enable interrupts if needed
  42.     // sei();
  43.     // 3. Place here main code
  44.  
  45.     int i = 0;
  46.  
  47.     while(1)
  48.     {
  49.    
  50.             while(pgm_read_word(TAB_ROM+i) != 0x0000)
  51.             {
  52.                 uint8_t a  = pgm_read_byte(TAB_ROM+i);
  53.                 PORTB= a;
  54.                 i++;
  55.             }
  56.        
  57.        
  58.    
  59.     }
  60.     //----------------------------------------------------------------------
  61.     // Program end
  62.     //----------------------------------------------------------------------
  63. }
  64. // -------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement