Guest User

Untitled

a guest
Dec 12th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1. /*
  2.  * Schrittmotortreiber.c
  3.  *
  4.  * Created: 02.10.2012 17:56:20
  5.  *  Author: Alexander
  6.  */
  7.  
  8. #include <avr/io.h>
  9. #include <avr/interrupt.h>
  10.  
  11. int main(void)
  12. {
  13.     //LED´s
  14.     DDRA |= (1 << PA4);
  15.     DDRA |= (1 << PA5);
  16.     DDRA |= (1 << PA6);
  17.    
  18.     //Taster
  19.     PORTB |= (1 << PB0);
  20.     PORTB |= (1 << PB1);
  21.     PORTB |= (1 << PB2);
  22.    
  23.     //L6203
  24.     DDRA |= (1 << PA0);
  25.     DDRA |= (1 << PA1);
  26.     DDRA |= (1 << PA2);
  27.     DDRA |= (1 << PA3);
  28.  
  29.    
  30.     //Timer0
  31.     TCCR0A |= (1 << WGM01);
  32.     TCCR0B |= (1 << CS01);
  33.     TCCR0B |= (1 << CS00);
  34.     OCR0A = 125-1;
  35.     sei();
  36.     TIMSK0 |= (1 << OCIEA);
  37.    
  38.     //Timer1
  39.    
  40.    
  41.    
  42.     //ADC
  43.         //ACD an PA7
  44.         ADMUX |= (1 << MUX0);
  45.         ADMUX |= (1 << MUX1);
  46.         ADMUX |= (1 << MUX2);
  47.        
  48.         //Prescaler
  49.         ADCSRA |= (1 << ADPS1);
  50.         ADCSRA |= (1 << ADPS2);
  51.        
  52.         //ADC Starten
  53.         ADCSRA |= (1 << ADEN);
  54.         ADCSRA |= (1 << ADSC);
  55.         ADCSRA |= (1 << ADATE);
  56.    
  57.     while(1)
  58.     {
  59.     /*  if(ADC > 250){
  60.             PORTA |= (1 << PA6);
  61.         }else{
  62.             PORTA &= ~(1 << PA6);
  63.         }
  64.                        
  65.        if(ADC > 500){
  66.            PORTA |= (1 << PA4);
  67.        }else{
  68.            PORTA &= ~(1 << PA4);
  69.        }
  70.        
  71.        if(ADC > 750){
  72.            PORTA |= (1 << PA5);
  73.        }else{
  74.            PORTA &= ~(1 << PA5);
  75.        }*/     
  76.     }
  77. }
  78.  
  79. ISR (TIMER0_COMPA_vect) {
  80.    
  81.     PORTA |= (1 << PA4);
  82. }
Add Comment
Please, Sign In to add comment