Gast
#260232
Hi ich wollte fragen ob der Code so funktionieren könnte. Hab leider
kein Oszi da.
Wenn der Timer läuft wird im 76 KHz Takt ein Pin getoggelt als
Trägerfrequenz. Die Senderoutinen schalten dann den Timer ein oder aus
um ein Bit zu senden.
#include "main.h"
uint8_t on=0x00;
uint16_t testbefehl = 0xAAAA;
void InitPorts(void){
}
//76KHz Timer
void InitTimer0(void){
TCCR0=0x00;
TCNT0=0x2e;
//TCCR0=0x01;
}
INTERRUPT (SIG_OVERFLOW0){
TCNT0=0x2e;
PORTC^=PORTC&(1<<5);
}
void InitDevice(void){
cli();
InitPorts();
InitTimer0();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x01;
sei();
}
void IRSend(uint16_t* befehl){
for(int i=0;i<14;i++){
Manchester((uint8_t)((*befehl>>i)&0x01));
}
for(int i=0;i<50;i++){
Delay_us(1778);
}
TCCR0=0x00;
PORTC&=~(1<<5);
}
void Manchester(uint8_t onebit){
switch(onebit){
case 0x00:
TCCR0=0x01;
Delay_us(889);
TCCR0=0x00;
Delay_us(889);
break;
case 0x01:
TCCR0=0x00;
Delay_us(889);
TCCR0=0x01;
Delay_us(889);
break;
}
}
void main(void){
IRSend(&testbefehl);
}