Hallo Leute ich bin gerade dabei die Version 2 meiner Bike Control Unit zu programmieren, aber irgendwie bekomme ich einen banalen Port nicht geschaltet. Ich habe an PC4 (TDO) einen ganz einfachen N-FET hängen der zwei kleine Orange Seiten-LEDs (30mA) schaltet. Allerdings passiert bei meinem unten angegebenen Quellcode garnichts. Der Port ist als ausgang definiert und die ansteuerung sollte auch richtig sein, aber dennoch erscheint der PORT C4 aus tristate, wenn ich die Kiste anreiß. wenn ich genau den gleichen Code auf einen anderen Port lege und dann an den FET Brücke (weil C4 tristate ist geht das) funktioniert die Steuerung. Habe schon den µC ausgetauscht aber der Fehler bleibt. Kann es sein, dass irgendwelche andere Programmierung den PORT blockiert???
Code:

// Programm for the Bike-Control V2.0 of S.Heidkamp//

//**************************************************//
//Includes:											//
#include <avr/io.h> 								//
#include <avr/interrupt.h>							//
#include <math.h>						 			//
#include <stdint.h>									//
#include <avr/eeprom.h>								//
													//
#define F_CPU		16000000UL						//
#include <util/delay.h>								//
//													//
//**************************************************//

//INPUTS: A7=ADCBAT;A1=CUR1;A2=CUR2;D2=DOWN(INT0);D3=UP(INT1);C3=LOCKED;B2=ALERT(INT2); D1=POWEROFF

volatile uint8_t SOUNDRISE=1;
volatile uint8_t WARNINGS=0;
volatile uint16_t COUNTDOWN1=0;
volatile uint8_t STATUS;

volatile uint16_t UBAT=740;
volatile uint16_t I1=500;
volatile uint16_t I2=500;
volatile uint16_t I_SET=100;

volatile uint8_t ADC_CHANNEL=0;
volatile uint8_t ADC_COUNT=0;
volatile uint16_t ADC_TMP=0;


volatile uint8_t GREEN_ENABLE=0;
volatile uint8_t GREEN_TIMER=0;
volatile uint8_t BACK_ENABLE=0;
volatile uint8_t BACK_TIMER=0;
volatile uint8_t SIDES_ENABLE=0;
volatile uint8_t SIDES_TIMER=0;

//**************************************************//
//Defines											//
#define TAKT		16000000UL						//
#define EEPROM		__attribute__((section(".eeprom")))// new symbol
//INPUTS											//
#define LOCKED		!(PINC & (1 << PC3))			// lowactive
#define OFFSWITCH	!(PIND & (1 << PD1))			// lowactive
#define VIBRATION	PINB & (1 << PB2)				// highactive
//OUTPUTS											//
#define	REDON		PORTC &=  ~(1<<PC7);			// lowactive
#define	REDOFF		PORTC |=  (1<<PC7);				//
#define REDISON		!(PINC & (1 << PC7))			//	
#define	GREENON		PORTC &=  ~(1<<PC6);			// lowactive
#define	GREENOFF	PORTC |=  (1<<PC6);				//
#define GREENISON	!(PINC & (1 << PC6))			//
#define	BACKOFF		PORTB &=  ~(1<<PB1);			// highactive
#define	BACKON		PORTB |=  (1<<PB1); 			//
#define BACKISON	PINB & (1 << PB1)				//
#define	SIDESOFF	PORTC &=  ~(1<<PC4);			// highactive
#define	SIDESON		PORTC |=  (1<<PC4);				//
#define SIDESAREON	PINC & (1 << PC4)				//
#define	POWEROFF	PORTD &=  ~(1<<PD0);			//
#define	POWERON		PORTD |=  (1<<PD0);				//
/*#define SIRENOFF	TCCR2 &= ~(1 << COM20);			//(OC2)
#define SIRENON		OCR2 = 200;TCCR2 |= (1 << COM20);//*/
#define LIGHTSOFF	TCCR1A &= ~((1 << COM1A1)|(1 << COM1B1));//
#define LIGHTSON	TCCR1A |= (1 << COM1A1)|(1 << COM1B1);//
#define NEARON		TCCR1A |= (1 << COM1A1);		//(OC1A) PD5
#define NEAROFF		TCCR1A &= ~(1 << COM1A1);		//
#define FARON		TCCR1A |= (1 << COM1B1);		//(OC1B) PD4
#define FAROFF		TCCR1A &= ~(1 << COM1B1);		//
#define VIBSENSOFF	GICR &=~(1<<INT2);				//
#define VIBSENSON	GIFR |=(1<<INTF2);GICR |=(1<<INT2);//
//STATUS											//
#define LIGHT 		0								//
#define ALLCLEAR 	1								//
#define NOISE		2								//
#define ATTENTION	3								//
#define ALERT		4								//
#define LOWBAT		5								//
#define SLEEP		6								//
//BRIGHTNESS
#define ULOW 		0								//  50 mA
#define LOW		 	1								// 100 mA
#define MEDIUM		2								// 350 mA
#define HIGH		3								// 700 mA
#define PULSE		4								//1000 mA
//ADJUSTMENTS										//
#define ADC_ADJUST	-24								//
//**************************************************//
 
void tasks(void)
{
}


int main(void) 
{ 
//Initiator
	
	DDRA = 0b00000000;								//Output Select
	DDRB = 0b00000010;								//Back
	DDRC = 0b11010000;								//RD GN SIDES
	DDRD = 0b10110001;								
	MCUCR |= (1<<ISC11)|(1<<ISC10)|(1<<ISC01)|(1<<ISC00);//External Interrupts at rising edge
	MCUCSR |= (1<<ISC2);							// External Interrupt at rising edge
	GICR |=(1<<INT0)|(1<<INT1);						// Enable Buttons

	POWERON;

	cli();
	//Timer 0										
	TCCR0 |= (1 << CS00)|(1 << CS02);				// normal mode, prescaler 1024
	TCNT0 = 256 - 156;								// Timer0 mit 156 neu vorladen: 156*1024/4MHz = 9,984ms ~ 10ms
	TIMSK |= (1 << TOIE0);							// Timer0 Interrupt freigegeben

	//Timer 1
	TCCR1A |= (1 << WGM11)|(1 << WGM10);			// 10-Bit PWM mode
	TCCR1B |= (1 << CS10)|(1 << WGM12);				// prescaler 1, freq. fixed, 16MHz/2^10=15,625kHz 
	OCR1A = 100;									// Standard 10% as start Value
	OCR1B = 100;									//
	TIMSK |= (1 << TOIE1);							// Timer1 Interrupt freigegeben*/
	
	//Timer 2
	
	//ADC
	
	REDON;

	sei();
//Mainprogramm

	while(1)
	{
		if(OFFSWITCH)
		{
			REDOFF;
			GREENOFF;
			LIGHTSOFF;
			POWEROFF;}
		GREEN_ENABLE = 1;
		BACK_ENABLE = 1;
		SIDES_ENABLE = 1;
		NEARON;
		FARON;
		VIBSENSON;
		//LIGHTSON;
		//SIRENON;
		//POWEROFF;
	}
	
	return 1; 
}

SIGNAL(SIG_INTERRUPT0)								//DOWN Button
{
	if(REDISON){
		REDOFF}
	else{
		REDON}
	
	if(OCR1A >100){
		OCR1A -=100;
		OCR1B -=100;}
		
	GIFR |=(1<<INTF0);
}

SIGNAL(SIG_INTERRUPT1)								//UP Button
{
	if(REDISON){
		REDOFF}
	else{
		REDON}

	if(OCR1A <1000){
		OCR1A +=100;
		OCR1B +=100;}

	GIFR |=(1<<INTF1);
}

SIGNAL(SIG_INTERRUPT2)								//ALERT signal
{
	if(REDISON){
		REDOFF}
	else{
		REDON}
	GIFR |=(1<<INTF2);		
}

SIGNAL(SIG_OVERFLOW0)								//0,01s Timer Unit
{
	TCNT0 = 256 - 156;								//new Preload

	if(GREEN_ENABLE)								//Green LED Control
	{
		GREEN_TIMER++;								
		//if(STATUS == LIGHT)						// Battery equivalent pulse 2s.
		{
			if(GREEN_TIMER >= 840-UBAT){
				GREENON;}
			else if(GREEN_TIMER == 0){
				GREENOFF;}
		}
	}

	if(BACK_ENABLE)									//Back LED Control
	{
		BACK_TIMER++;
		if(BACK_TIMER == 25)
			BACKON;
		if(BACK_TIMER>=50){
			BACKOFF;
			BACK_TIMER = 0;}
	}

	if(SIDES_ENABLE)									//Side LEDs Control
	{
		SIDES_TIMER++;
		if(SIDES_TIMER == 20)
			SIDESON;
		if(SIDES_TIMER>=40){
			SIDESOFF;
			SIDES_TIMER = 0;}
	}
}

SIGNAL(SIG_OVERFLOW1)								//Timer1 Unit 250µs
{
}

SIGNAL(SIG_ADC)
{
}
[/flash]