All pastes #211759 Raw Edit

Mine

public text v1 · immutable
#211759 ·published 2006-10-20 13:51 UTC
rendered paste body

	
 #include "bulb.h"


uint8_t duty_cycle=0;

void init_bulb()
{
	BULB_TCCRA &= ~_BV(WGM10);
	BULB_TCCRA |=  _BV(WGM11);
	
	BULB_TCCRA &= ~_BV(COM1A0);
	BULB_TCCRA |= _BV(COM1A1);
	
	BULB_TCCRB |=  _BV(WGM12);
	BULB_TCCRB |=  _BV(WGM13);
	BULB_TCCRB |=  _BV(CS10);
	
	ICR1=100;
	// clear output compare value A
	BULB_OCR=0;
	
	
	
	 
	BULB_DDR   = _BV(BULB_PIN);                // PD3 als Ausgang schalten
	
	
}                                                                       
 
void set_bulb(uint8_t duty_cycle)
{
	BULB_OCR=duty_cycle;

}



#ifndef __BULB_H__
#define __BULB_H__
#include <avr/io.h>                                                                                         
#include <stdio.h>                                                                                          
#include <avr/pgmspace.h>                                                                                   
#include <avr/interrupt.h>                                                                                  
#include <avr/signal.h>                                                                                     
                          
#define BULB_PORT PORTB
#define BULB_PIN PB5
#define BULB_DDR DDRB

#define BULB_TCCRA TCCR1A
#define BULB_TCCRB TCCR1B
#define BULB_OCR OCR1A
#define BULB_ICR ICR1


void init_bulb(void);
void set_bulb(uint8_t duty_cycle);
void button(void);

#endif  /* ifndef __bsp15_H__ */