sooooooo...
da ich mal wieder keine antwort bekomme... ...hab ich mir selbst geholfen.
Prima, so sollte es sein. Selber Nachdenken führt gelegentlich auch zum Ziel.
Deine vorige Programmversion mit Ausgabe der Tasten- und OCR2-Werte stolperte über den Mix aus IR-Abstandsmessung und IR-Kommunikation mit dem Terminal. So funktioniert es bei meinem asuro mit alter Lib:
Code:
/*******************************************************************************
*
* Description: Asuro IR-Detektor Testprogramm
*
*****************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* any later version. *
***************************************************************************/
#include "asuro.h"
#include <stdlib.h>
static unsigned char ocr2 = 0xFE;
void InitIRDetect(void)
{
DDRD |= (1 << DDD1); // Port D1 als Ausgang
PORTD &= ~(1 << PD1); // PD1 auf LOW
UCSRB = 0;
OCR2 = ocr2;
}
void InitUart(void)
{
OCR2 = 0x91; // duty cycle fuer 36kHz
}
int main(void)
{
unsigned char sw;
Init();
InitIRDetect();
while (1)
{
if (PIND & (1 << PD0))
StatusLED(GREEN);
else
StatusLED(RED);
sw = PollSwitch();
if (sw & 0x01)
ocr2 = 0xFE; //Pulsbreite 1
if (sw & 0x02)
ocr2 = 0xFD; //Pulsbreite 2
if (sw & 0x04)
ocr2 = 0xFB; //Pulsbreite 4
if (sw & 0x08)
ocr2 = 0xF7; //Pulsbreite 8
if (sw & 0x10)
ocr2 = 0xEF; //Pulsbreite 16
if (sw & 0x20)
ocr2 = 0x90; //Pulsbreite 110
if (sw)
{
OCR2 = 0x91;
PrintInt(sw);
SerWrite("-", 1);
PrintInt(ocr2);
SerWrite("\n\r", 2);
UCSRB = 0;
OCR2=ocr2;
}
Msleep(100);
}
return 0;
}
Das sollte auch mit der 2.8er Lib funktionieren weil sie den Timer richtig parametriert.
Gruß
mic
Lesezeichen