Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Schrittmotortreiber.c
- *
- * Created: 02.10.2012 17:56:20
- * Author: Alexander
- */
- #include <avr/io.h>
- #include <avr/interrupt.h>
- int main(void)
- {
- //LED´s
- DDRA |= (1 << PA4);
- DDRA |= (1 << PA5);
- DDRA |= (1 << PA6);
- //Taster
- PORTB |= (1 << PB0);
- PORTB |= (1 << PB1);
- PORTB |= (1 << PB2);
- //L6203
- DDRA |= (1 << PA0);
- DDRA |= (1 << PA1);
- DDRA |= (1 << PA2);
- DDRA |= (1 << PA3);
- //Timer0
- TCCR0A |= (1 << WGM01);
- TCCR0B |= (1 << CS01);
- TCCR0B |= (1 << CS00);
- OCR0A = 125-1;
- sei();
- TIMSK0 |= (1 << OCIEA);
- //Timer1
- //ADC
- //ACD an PA7
- ADMUX |= (1 << MUX0);
- ADMUX |= (1 << MUX1);
- ADMUX |= (1 << MUX2);
- //Prescaler
- ADCSRA |= (1 << ADPS1);
- ADCSRA |= (1 << ADPS2);
- //ADC Starten
- ADCSRA |= (1 << ADEN);
- ADCSRA |= (1 << ADSC);
- ADCSRA |= (1 << ADATE);
- while(1)
- {
- /* if(ADC > 250){
- PORTA |= (1 << PA6);
- }else{
- PORTA &= ~(1 << PA6);
- }
- if(ADC > 500){
- PORTA |= (1 << PA4);
- }else{
- PORTA &= ~(1 << PA4);
- }
- if(ADC > 750){
- PORTA |= (1 << PA5);
- }else{
- PORTA &= ~(1 << PA5);
- }*/
- }
- }
- ISR (TIMER0_COMPA_vect) {
- PORTA |= (1 << PA4);
- }
Add Comment
Please, Sign In to add comment