Attack und Release für den Mithörton implementiert.

Sinustabelle auf 64 Werte (konfigurierbar auch für
128 Werte) geändert.
main
Tom 10 months ago
parent 47b030ab96
commit c815b6c36b

@ -0,0 +1,734 @@
/** \brief BJ-Keyer
:
Morsekeyer von DL7BJ
tom@dl7bj.de
OLED functions from https://github.com/Sylaina/oled-display
@verbatim
History
--------------------------------------------------------------------------
2012-05-24 DL7BJ erste Version
2013-05-10 DL7BJ Generierung des Mithörtons als Sinus mit PWM/DDS
2013-07-15 DL7BJ Änderungen der Keyerfunktionen
2013-07-19 DL7BJ Beep/Boop (Spielkram)
2013-10-20 DL7BJ Änderungen der PWM Funktionen für besseren Sinus
2022-04-10 DL7BJ erste Leiterplatten für Prototyp (bisher Lochraster)
2022-09-02 DL7BJ viele Softwareänderungen, neuer Filter für PWM
2022-09-11 DL7BJ Encoder, LC-Display, Frontplatine "entsorgt"
2023-06-28 DL7BJ Port Anpassungen an neue Leiterplatte V1.01
ATMEGA328(P)
----------
(PCINT14/_RESET) PC6 -| 1 28|- PC5 (ADC5/SCL/PCINT13)
(PCINT16/RXD) PD0 -| 2 27|- PC4 (ADC4/SDA/PCINT12)
(PCINT17/TXT) PD1 -| 3 26|- PC3 (ADC3/PCINT11)
(PCINT18/INT0) PD2 -| 4 25|- PC2 (ADC2/PCINT10)
(PCINT19/OC2B/INT1) PD3 -| 5 24|- PC1 (ADC1/PCINT9)
(PCINT20/XCK/T0) PD4 -| 6 23|- PC0 (ADC0/PCINT8)
VCC -| 7 22|- GND
GND -| 8 21|- AREF
(PCINT6/XTAL1/TOSC1) PB6 -| 9 20|- AVCC
(PCINT7/XTAL2/TOSC2) PB7 -|10 19|- PB5 (SCK/PCINT5)
(PCINT21/OC0B/T1) PD5 -|11 18|- PB4 (MISO/PCINT4)
(PCINT22/OC0A/AIN0) PD6 -|12 17|- PB3 (MOSI/OC2A/PCINT3)
(PCINT23/AIN1) PD7 -|13 16|- PB2 (SS/OC1B/PCINT2)
(PCINT0/CLK0/ICP1) PB0 -|14 15|- PB1 (OC1A/PCINT1)
----------
Pin 1 - PC6 - Reset Pin 28 - PC5 - SCL Display
Pin 2 - PD0 - RxD Pin 27 - PC4 - SDA Display
Pin 3 - PD1 - TxD Pin 26 - PC3 - LED Key
Pin 4 - PD2 - Left Paddle Pin 25 - PC2 - TRX 2 Out
Pin 5 - PD3 - Right Paddle Pin 24 - PC1 - TRX 1 Out
Pin 6 - PD4 - Straight Key Pin 23 - PC0 - Mem 4
Pin 19 - PB5 - Mem 5
Pin 11 - PD5 - Mem 1 Pin 18 - PB4 - _Audio SD
Pin 12 - PD6 - Mem 2 Pin 17 - OC2A - Audio PWM output
Pin 13 - PD7 - Mem 3 Pin 16 - PB2 - Encoder Switch
Pin 14 - PB0 - Encoder A Pin 15 - PB1 - Encoder B
Value 1 2 4 8 32 64 128 255
Bit 1 2 3 4 5 6 7 8
Pin 0 1 2 3 4 5 6 7
@endverbatim
*/
#include "bj-keyer.h"
// Additional files
#include "functions.c"
#define LENGTH 256
#define AMP 127
#define OFFSET 128
#define PI2 6.283185
/**
* \brief Initialsieren der Timer
*
* Alle Parameter der Timer basieren auf 16MHz Systemtakt.
*
* Timer 0 - 8 Bit timer für 1ms
* Timer 2 - 8 Bit timer für PWM zur Erzeugung des Sinustons
* Timer 1A - 16 Bit timer zur Erzeugung der Hüllkurve
* Timer 1B - 16 Bit timer wird nicht benutzt
*
* T - dot duration
* wpm - Words per Minute based on PARIS
* Formula T = 1200 / wpm
* Minimum speed 10 wpm - dot duration 120ms
* Maximum speed 99 wpm - dot duration 12ms
*
*/
void InitTimer(void)
{
cli();
// Timer 2 PWM
TCCR2A = 0;
TCCR2B = 0;
// No prescaling
sbi(TCCR2B,CS20);
// Clear OC2A on compare match
sbi(TCCR2A,COM2A1);
// Fast PWM Mode
sbi(TCCR2A,WGM20);
sbi(TCCR2A,WGM21);
// Phase Correct PWM
//sbi(TCCR2A,WGM22);
//sbi(TCCR2A,WGM20);
// Initial value
OCR2A = 0x80;
sbi(DDRB,PB3);
// Timer 1 für die Sinus Hüllkurve
TCCR1A = 0; TCCR1B = 0; TIMSK1 = 0;
// CTC Mode
sbi(TCCR1B,WGM12);
// Prescaling 8
sbi(TCCR1B,CS11);
// Output Compare Match Interrupt Enable
OCR1A = 51; // 600Hz
sbi(TIMSK1,OCIE1A);
// Timer 0 1ms für diverse Zähler
TCCR0A = 0; TCCR0B = 0; TCNT0 = 0;
cbi(TCCR0A,WGM00);
sbi(TCCR0A,WGM01);
cbi(TCCR0B,WGM02); // CTC Mode 2 Immediate
cbi(TCCR0B,CS02);
sbi(TCCR0B,CS01);
sbi(TCCR0B,CS00); // prescaler 64
OCR0A = 249; // CTC 1ms
sbi(TIMSK0,OCIE0A); // Enable Timer 0 CTC
sei();
}
void Init()
{
cli(); // disable all interrupts
MachineMode = NORMAL;
SendStatus = SENDING_NOTHING;
// PORTB
DDRB = 0x00;
// Interne PullUps einschalten
sbi(PORTB,PB0);
sbi(PORTB,PB1);
sbi(PORTB,PB2);
sbi(PORTB,PB3);
sbi(PORTB,PB5);
sbi(PORTB,AUDIO_EN);
// Ein- und Ausgänge festlegen
sbi(DDRB,PB3); // PWM
sbi(DDRB,AUDIO_EN);
// Audio Verstärker abschalten
// cbi(PORTB,AUDIO_EN);
// PORTC
sbi(DDRC,MORSE_LED);
// PORTD
// Ein- und Ausgänge festlegen
DDRD = 0x00;
// Interne PullUps für die Eingänge abschalten
cbi(PORTD,LEFT_PADDLE);
cbi(PORTD,RIGHT_PADDLE);
cbi(PORTD,STRAIGHT_KEY);
t_element_length = (uint16_t)1200/bConfig.wpm;
// Pin Change Interrupts Port D - Keys
// PD4 - StraightKey - PCINT20 - Pin Change Interrupt 20
// PD3 - Right Paddle - PCINT19 - Pin Change Interrupt 19
// PD2 - Left Paddle - PCINT18 - Pin Change Interrupt 18
sbi(PCICR,PCIE2);
sbi(PCMSK2,PCINT18);
sbi(PCMSK2,PCINT19);
sbi(PCMSK2,PCINT20);
// Init serial
UBRR0=UBRR_VALUE; // Set baud rate
sbi(UCSR0B,TXEN0); // Enable TX
sbi(UCSR0B,RXEN0); // Enable RX
sbi(UCSR0B,RXCIE0); // RX complete interrupt
sbi(UCSR0C,UCSZ01); // no parity, 1 stop bit
sbi(UCSR0C,UCSZ01); // 8-bit data
InitTimer();
EncoderInit();
// Initialisierung Menüvariablen
bMenuCtrl.ClrScr = 1;
bMenuCtrl.Update = 1;
bMenuCtrl.Config = 0;
bMenuCtrl.buttonPressed = 0;
bMenuCtrl.WriteEEProm = 0;
bMenuCtrl.buttonPressedLong = 0;
// Initialisierung Konfiguration
bConfig.iambic = 1;
bConfig.sidetone_f = 600;
bConfig.sidetone = 1;
bConfig.trx = 0;
bConfig.weight = 50;
bConfig.wpmbpm = 1;
bConfig.wpm = 15;
bConfig.ratio = 30;
bConfig.reverse = 0;
bConfig.SinusRising = 6;
sei(); // enable all interrupts
}
/** \brief 16 Bit Timer 1A
*
* Timer 1A interrupt
* Overflow interrupt every 64µs
*
*/
//ISR(TIMER1_OVF_vect)
//{
// //sCurrentTimer += 0xffff;
// PORTD ^= (1<<PD1);
//}
//
ISR(TIMER1_COMPA_vect)
{
IntDisable();
if(StateRising > 0)
{
OCR2A = (pgm_read_byte_near(sinewave+icnt) >> StateRising);
}
else
{
OCR2A = pgm_read_byte_near(sinewave+icnt);
}
icnt++;
if(icnt > SINEWAVELENGTH - 1)
{
icnt = 0;
if(StateRising > 0)
StateRising--;
}
IntEnable();
}
/** \brief 8 Bit Timer 0
*
* The Timer 0 CTC interrupt
* Dieser Interrupt wird jede Millisekunde erzeugt
*
*/
ISR(TIMER0_COMPA_vect)
{
ms++;
StoreEEprom++;
MenuCtrlTimer++;
mselement++; // element length of dit or dat
t_wait++;
l_timer++;
encoder_timer++;
if(l_timer >= L_WAIT){
l_timer = 0;
}
// Alle 5ms den Drehencoder abfragen
if(encoder_timer > 5) {
EncoderPolling();
// Schalter vom Drehencoder abfragen
if(EncoderGetButtonState() == ButtonPressed_Short)
{
bMenuCtrl.buttonPressed = 1;
SendSerialString("Button pressed short\r\n");
}
if(EncoderGetButtonState() == ButtonPressed_Long)
{
bMenuCtrl.buttonPressedLong = 1;
SendSerialString("Button pressed long\r\n");
}
}
// Wpm verändert?
if((StoreEEprom > 1000) && (bMerker.WpMChanged))
{
StoreEEprom = 0;
bMerker.WriteWpMEEProm = 1;
bMerker.WpMChanged = 0;
}
// Konfiguration nach 3 Sekunden verlassen
// if((MenuCtrlTimer > 3000) && (bMenuCtrl.Config == 1))
// {
// bMenuCtrl.Config = 0;
// bMenuCtrl.Update = 1;
// bMenuCtrl.ClrScr = 1;
// BeepBoop();
// }
}
/** \brief 8 Bit Timer 2
*
* Timer 2 overflow interrupt
* Mit diesem Interrupt wird der nächste Wert für die
* Erzeugung des Sinus für den Mithörton geladen.
*
*/
ISR(TIMER2_OVF_vect)
{
// phaccu = phaccu + tword_m;
// icnt = phaccu >> 24;
// OCR2A = pgm_read_byte_near(sinewave+icnt);
}
/** \brief Pin Change Interupts für Paddle und StraightKey
*
* Pin Change Interrupt Vector für die Tasteneingänge
* Str Pa2 Pa1
* PORTD PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0
* x80 x40 x20 x10 x8 x4 x2 x1
*
*/
ISR(PCINT2_vect)
{
uint8_t changedbits;
changedbits = PIND ^ keyhistory;
keyhistory = PIND;
if(changedbits & (1<<STRAIGHT_KEY))
{
if(PIND & (1<<STRAIGHT_KEY))
{
PORTC &= ~(1<<MORSE_LED);
SideToneOff();
}
else
{
PORTC |= (1<<MORSE_LED);
SideToneOn();
}
}
}
ISR(USART_RX_vect)
{
unsigned char data;
data = UDR0;
SendSerialChar(data);
}
/** \brief ClearSendBuffer
*
*/
void ClearSendBuffer(void)
{
// sendbufferbytes = 0;
}
/** \brief CheckDitPaddle
*
*
*/
void CheckDitPaddle(void)
{
uint8_t pinvalue = 0;
uint8_t ditpaddle = 0;
if(PaddleMode == PADDLE_NORMAL) // no reverse paddle
ditpaddle = LEFT_PADDLE;
else
ditpaddle = RIGHT_PADDLE; // reverse paddle
pinvalue = ReadKeyPin(ditpaddle);
if(pinvalue == 0)
DitBuffer = 1;
}
/*
** CheckDahPaddle
*/
void CheckDahPaddle(void)
{
uint8_t pinvalue = 0;
uint8_t dahpaddle = 0;
if(PaddleMode == PADDLE_NORMAL) // no reverse paddle
dahpaddle = RIGHT_PADDLE;
else
dahpaddle = LEFT_PADDLE; // reverse paddle
pinvalue = ReadKeyPin(dahpaddle);
if(pinvalue == 0) {
if(DahBuffer == 0) {
DahCounter++;
DitCounter = 0;
}
DahBuffer = 1;
}
}
/*
** DoMorse
*/
void DoMorse(void)
{
if((KeyerMode == IAMBIC_A) || (KeyerMode == IAMBIC_B) || KeyerMode == SINGLE_PADDLE)
{
if((KeyerMode == IAMBIC_A) && (IambicFlag) && (ReadKeyPin(LEFT_PADDLE)))
{
IambicFlag = 0;
DitBuffer = 0;
DahBuffer = 0;
}
else
{
if(DitBuffer)
{
DitBuffer = 0;
SendDit(MANUAL_SENDING);
}
if(DahBuffer)
{
DahBuffer = 0;
SendDah(MANUAL_SENDING);
}
}
}
else
{
if(KeyerMode == STRAIGHT)
{
if(DitBuffer)
{
DitBuffer = 0;
TXSidetoneKey(1,MANUAL_SENDING);
}
else
{
TXSidetoneKey(0,MANUAL_SENDING);
}
DitCounter = 0;
}
}
}
void ConfigMenue(void)
{
char line[22];
lcd_charMode(NORMAL);
lcd_gotoxy(0,0);
sprintf(line,"%s - %i","Konfiguration", bMenuCtrl.CurMenue);
lcd_puts(line);
lcd_charMode(DOUBLESIZE);
lcd_gotoxy(0,3);
lcd_puts(CLEARLINE);
switch(bMenuCtrl.CurMenue)
{
case M_TRX1:
lcd_gotoxy(0,3);
if((bConfig.trx == 1) || (bConfig.trx == 0))
sprintf(line,"[%s]", "TRX 1");
else
sprintf(line,"%s", "TRX 1");
lcd_puts(line);
break;
case M_TRX2:
lcd_gotoxy(0,3);
if((bConfig.trx == 2) || (bConfig.trx == 0))
sprintf(line,"[%s]", "TRX 2");
else
sprintf(line,"%s", "TRX 2");
lcd_puts(line);
break;
case M_IAMBICA:
lcd_gotoxy(0,3);
if(bConfig.iambic == 1)
sprintf(line,"[%s]", "Iambic A");
else
sprintf(line,"%s", "Iambic A");
lcd_puts(line);
break;
case M_IAMBICB:
lcd_gotoxy(0,3);
if(bConfig.iambic == 2)
sprintf(line,"[%s]", "Iambic B");
else
sprintf(line,"%s", "Iambic B");
lcd_puts(line);
break;
case M_REVERSE:
lcd_gotoxy(0,3);
if(bConfig.reverse == 0)
sprintf(line,"%s", "L . R -");
else
sprintf(line,"%s", "L - R .");
lcd_puts(line);
break;
case M_RATIO:
lcd_gotoxy(0,3);
if(bConfig.ratio == 30)
sprintf(line,"%s", "Ratio 3:1");
else
sprintf(line,"%s %f:1", "Ratio", bConfig.ratio/10);
lcd_puts(line);
break;
case M_TON_FREQ:
lcd_gotoxy(0,3);
if(bConfig.sidetone_f == 650)
sprintf(line,"%s", "Ton 650Hz");
else
sprintf(line,"%s %uHz", "Ton", bConfig.sidetone_f);
lcd_puts(line);
break;
case M_TON:
lcd_gotoxy(0,3);
if(bConfig.ratio == 1)
sprintf(line,"%s", "Ton an");
else
sprintf(line,"%s", "Ton aus");
lcd_puts(line);
break;
case M_WPMBPM:
lcd_gotoxy(0,3);
if(bConfig.wpmbpm == 0)
sprintf(line,"%s", "WpM");
else
sprintf(line,"%s", "BpM");
lcd_puts(line);
break;
}
bMenuCtrl.Update = 0;
lcd_charMode(NORMAL);
}
/** \brief UpdateDisplay
*
* Aktualisierung der Anzeigen auf dem Display je nach
* aktueller Funktion.
*
* DOUBLESIZE 4x10 character
* NORMALSIZE 8x21 character
*/
void UpdateDisplay(void)
{
char line[22];
if(bMenuCtrl.Update)
{
if(bMenuCtrl.ClrScr)
{
lcd_clrscr();
bMenuCtrl.ClrScr = 0;
}
if(!(bMenuCtrl.Config))
{
lcd_charMode(DOUBLESIZE);
lcd_gotoxy(4,3);
if(bConfig.wpmbpm)
sprintf(line,"%i WpM ",bConfig.wpm);
else
sprintf(line,"%i BpM ", bConfig.wpm*5);
lcd_puts(line);
lcd_charMode(NORMAL);
lcd_gotoxy(13,0);
if(bConfig.iambic == 1)
sprintf(line,"%s", IambicA);
if(bConfig.iambic == 2)
sprintf(line,"%s", IambicB);
lcd_puts(line);
lcd_gotoxy(0,0);
if(bConfig.trx == 1)
sprintf(line, "%s", Trx1);
if(bConfig.trx == 2)
sprintf(line, "%s", Trx2);
if(bConfig.trx == 0)
sprintf(line, "%s %s", Trx1, Trx2);
lcd_puts(line);
}
if(bMenuCtrl.Config)
{
ConfigMenue();
}
bMenuCtrl.Update = 0;
}
}
void Drehencoder(void)
{
int8_t st = 0;
static int8_t last;
if(!(bMenuCtrl.Config))
{
EncoderMinMax(5,50);
st = EncoderRead(1);
if(bConfig.wpm != st)
{
bConfig.wpm = st;
bMerker.WpMChanged = 1;
bMenuCtrl.Update = 1;
}
}
if((bMenuCtrl.buttonPressed == 1) && (bMenuCtrl.Config == 0))
{
bMenuCtrl.Config = 1;
MenuCtrlTimer = 0;
bMenuCtrl.buttonPressed = 0;
}
if((bMenuCtrl.buttonPressedLong == 1) && (bMenuCtrl.Config == 1))
{
bMenuCtrl.Config = 0;
bMenuCtrl.Update = 1;
bMenuCtrl.buttonPressedLong = 0;
bMenuCtrl.buttonPressed = 0;
bMenuCtrl.m_buttonPressed = 0;
bMenuCtrl.m_buttonPressed = 0;
MenuCtrlTimer = 0;
}
if(bMenuCtrl.Config == 1)
{
if(!bMenuCtrl.buttonPressed)
{
EncoderMinMax(1,M_MAX);
st = EncoderRead(1);
sprintf(sdebug,"Encoder %i\r\n",st);
SendSerialString(sdebug);
if(last != st)
{
bMenuCtrl.CurMenue = st;
bMenuCtrl.Update = 1;
}
last = st;
}
if(bMenuCtrl.buttonPressed)
{
bMenuCtrl.m_buttonPressed = 1;
bMenuCtrl.buttonPressed = 0;
}
if(bMenuCtrl.m_buttonPressed == 1)
{
UpdateDisplay();
switch(bMenuCtrl.CurMenue)
{
case M_TRX1:
if(bConfig.trx == 2)
bConfig.trx = 0;
else
bConfig.trx = 1;
bMenuCtrl.m_buttonPressed = 0;
break;
case M_TRX2:
if(bConfig.trx == 1)
bConfig.trx = 0;
else
bConfig.trx = 2;
bMenuCtrl.m_buttonPressed = 0;
break;
case M_IAMBICA:
bConfig.iambic = 1;
bMenuCtrl.m_buttonPressed = 0;
break;
case M_IAMBICB:
bConfig.iambic = 2;
bMenuCtrl.m_buttonPressed = 0;
break;
case M_REVERSE:
if(bConfig.reverse == 1)
bConfig.reverse = 0;
else
bConfig.reverse = 1;
bMenuCtrl.m_buttonPressed = 0;
break;
case M_RATIO:
EncoderMinMax(15,30);
st = EncoderRead(1);
bConfig.ratio = st;
if(bConfig.ratio > 30) bConfig.ratio = 30;
if(bConfig.ratio < 15) bConfig.ratio = 15;
bMenuCtrl.Update = 1;
break;
case M_TON_FREQ:
break;
}
}
}
}
/*
** main
*/
int main(void)
{
Init();
SideToneOff();
lcd_init(LCD_DISP_ON);
lcd_charMode(DOUBLESIZE);
lcd_home();
lcd_puts(PRG);
lcd_gotoxy(1,2);
lcd_puts(VER);
lcd_gotoxy(2,4);
lcd_puts(CALL);
delayms(1000);
MachineMode = NORMAL;
KeyerMode = IAMBIC_A;
ReadEEProm_WpM();
SendSerialString(CLRSCR);
SendSerialString("BJ-Keyer V1.00\r\n");
SendSerialString("Ready!\r\n");
EncoderWrite(bConfig.wpm);
BeepBoop();
SetFrequency(600);
while(1)
{
Drehencoder();
if(bMerker.WriteWpMEEProm)
WriteEEProm_WpM();
UpdateDisplay();
// if(MachineMode == NORMAL)
// {
// CheckPaddles();
// DoMorse();
// }
if(MachineMode == COMMAND)
{
}
}
}

@ -0,0 +1,102 @@
\relax
\providecommand\hyper@newdestlabel[2]{}
\providecommand*\new@tpo@label[2]{}
\providecommand\babel@aux[2]{}
\@nameuse{bbl@beforestart}
\catcode `"\active
\providecommand\HyperFirstAtBeginDocument{\AtBeginDocument}
\HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined
\global\let\oldcontentsline\contentsline
\gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}
\global\let\oldnewlabel\newlabel
\gdef\newlabel#1#2{\newlabelxx{#1}#2}
\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
\AtEndDocument{\ifx\hyper@anchor\@undefined
\let\contentsline\oldcontentsline
\let\newlabel\oldnewlabel
\fi}
\fi}
\global\let\hyper@last\relax
\gdef\HyperFirstAtBeginDocument#1{#1}
\providecommand\HyField@AuxAddToFields[1]{}
\providecommand\HyField@AuxAddToCoFields[2]{}
\providecommand\BKM@entry[2]{}
\babel@aux{ngerman}{}
\BKM@entry{id=1,dest={636861707465722E31},srcline={135},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030465C303030755C3030306E5C3030306B5C303030745C303030695C3030306F5C3030306E5C303030655C3030306E}
\@writefile{toc}{\contentsline {chapter}{\numberline {1}Funktionen}{5}{chapter.1}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\BKM@entry{id=2,dest={636861707465722E32},srcline={149},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030485C303030695C3030306E5C303030775C303030655C303030695C303030735C303030655C3030305C3034305C3030307A5C303030755C303030725C3030305C3034305C303030445C3030306F5C3030306B5C303030755C3030306D5C303030655C3030306E5C303030745C303030615C303030745C303030695C3030306F5C3030306E}
\@writefile{toc}{\contentsline {chapter}{\numberline {2}Hinweise zur Dokumentation}{7}{chapter.2}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\BKM@entry{id=3,dest={636861707465722E33},srcline={153},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030475C303030725C303030755C3030306E5C303030645C3030306C5C303030615C303030675C303030655C3030306E}
\BKM@entry{id=4,dest={73656374696F6E2E332E31},srcline={155},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030425C303030655C303030745C303030725C303030695C303030655C303030625C303030735C303030615C303030725C303030745C303030655C3030306E5C3030305C3034305C303030655C303030695C3030306E5C303030655C303030735C3030305C3034305C3030304D5C3030306F5C303030725C303030735C303030655C3030302D5C3030304B5C303030655C303030795C303030655C303030725C30303073}
\BKM@entry{id=5,dest={73756273656374696F6E2E332E312E31},srcline={157},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C3030305A5C303030655C303030695C303030745C303030765C303030655C303030725C303030685C303030615C3030306C5C303030745C303030655C3030306E}
\@writefile{toc}{\contentsline {chapter}{\numberline {3}Grundlagen}{9}{chapter.3}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {3.1}Betriebsarten eines Morse-Keyers}{9}{section.3.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.1.1}Zeitverhalten}{9}{subsection.3.1.1}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {3.1}{\ignorespaces Diagramm Mode A\relax }}{9}{figure.caption.4}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {3.2}{\ignorespaces Diagramm Mode B\relax }}{9}{figure.caption.5}\protected@file@percent }
\BKM@entry{id=6,dest={636861707465722E34},srcline={212},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030425C303030655C303030645C303030695C303030655C3030306E5C303030755C3030306E5C30303067}
\BKM@entry{id=7,dest={73656374696F6E2E342E31},srcline={214},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030545C303030615C303030735C303030745C303030615C303030745C303030755C303030725C303030625C303030655C3030306C5C303030655C303030675C303030755C3030306E5C30303067}
\BKM@entry{id=8,dest={73756273656374696F6E2E342E312E31},srcline={216},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C3030305C3333345C303030625C303030655C303030725C303030735C303030695C303030635C303030685C30303074}
\@writefile{toc}{\contentsline {chapter}{\numberline {4}Bedienung}{11}{chapter.4}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {4.1}Tastaturbelegung}{11}{section.4.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.1.1}Übersicht}{11}{subsection.4.1.1}\protected@file@percent }
\BKM@entry{id=9,dest={636861707465722E35},srcline={220},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030535C303030635C303030685C303030615C3030306C5C303030745C303030755C3030306E5C30303067}
\BKM@entry{id=10,dest={73656374696F6E2E352E31},srcline={222},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030425C303030655C303030735C303030635C303030685C303030725C303030655C303030695C303030625C303030755C3030306E5C30303067}
\@writefile{toc}{\contentsline {chapter}{\numberline {5}Schaltung}{13}{chapter.5}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {5.1}Beschreibung}{13}{section.5.1}\protected@file@percent }
\@writefile{lot}{\contentsline {table}{\numberline {5.1}{\ignorespaces Programmierpunkte Teil 1\relax }}{13}{table.caption.6}\protected@file@percent }
\BKM@entry{id=11,dest={636861707465722E36},srcline={233},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030425C303030655C303030735C303030635C303030685C303030725C303030655C303030695C303030625C303030755C3030306E5C303030675C3030305C3034305C303030645C303030655C303030725C3030305C3034305C303030485C303030615C303030725C303030645C303030775C303030615C303030725C30303065}
\@writefile{toc}{\contentsline {chapter}{\numberline {6}Beschreibung der Hardware}{15}{chapter.6}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lot}{\contentsline {table}{\numberline {6.1}{\ignorespaces Klemmenbelegung\relax }}{15}{table.caption.7}\protected@file@percent }
\BKM@entry{id=12,dest={636861707465722E37},srcline={243},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030425C303030655C303030735C303030635C303030685C303030725C303030655C303030695C303030625C303030755C3030306E5C303030675C3030305C3034305C303030645C303030655C303030725C3030305C3034305C303030535C3030306F5C303030665C303030745C303030775C303030615C303030725C30303065}
\BKM@entry{id=13,dest={73656374696F6E2E372E31},srcline={244},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030545C303030695C3030306D5C303030655C303030725C3030305C3034305C30303031}
\BKM@entry{id=14,dest={73756273656374696F6E2E372E312E31},srcline={251},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030545C303030695C3030306D5C303030655C303030725C3030305C3034305C303030655C303030695C3030306E5C303030735C303030745C303030655C3030306C5C3030306C5C303030655C3030306E}
\BKM@entry{id=15,dest={73656374696F6E2E372E32},srcline={258},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030535C303030695C3030306E5C303030755C303030735C3030305C3034305C3030304D5C303030695C303030745C303030685C3030305C3336365C303030725C303030745C3030306F5C3030306E5C3030305C3034305C303030645C303030755C303030725C303030635C303030685C3030305C3034305C303030505C303030755C3030306C5C303030735C303030775C303030655C303030695C303030745C303030655C3030306E5C3030306D5C3030306F5C303030645C303030755C3030306C5C303030615C303030745C303030695C3030306F5C3030306E}
\BKM@entry{id=16,dest={73756273656374696F6E2E372E322E31},srcline={264},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030475C303030725C303030755C3030306E5C303030645C3030306C5C303030615C303030675C303030655C3030306E}
\@writefile{toc}{\contentsline {chapter}{\numberline {7}Beschreibung der Software}{17}{chapter.7}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {7.1}Timer 1}{17}{section.7.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {7.1.1}Timer einstellen}{17}{subsection.7.1.1}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {7.2}Sinus Mithörton durch Pulsweitenmodulation}{17}{section.7.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {7.2.1}Grundlagen}{17}{subsection.7.2.1}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {7.1}{\ignorespaces Pulswellenmodulation\relax }}{18}{figure.caption.8}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\nonumberline Pulsweitenmodulation}{18}{subsubsection*.10}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {7.2}{\ignorespaces Symmetrisches Rechtecksignal an PB3\relax }}{19}{figure.caption.11}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {7.3}{\ignorespaces PWM - Tastgrad - Sinus\relax }}{20}{figure.caption.12}\protected@file@percent }
\BKM@entry{id=17,dest={73756273656374696F6E2E372E322E32},srcline={397},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030535C303030695C3030306E5C303030755C303030735C303030745C303030615C303030625C303030655C3030306C5C3030306C5C30303065}
\@writefile{lot}{\contentsline {table}{\numberline {7.1}{\ignorespaces OCR1A Werte für verschiedene Frequenzen des Mithörtons\relax }}{21}{table.caption.13}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {7.2.2}Sinustabelle}{21}{subsection.7.2.2}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {7.4}{\ignorespaces Sinus nach Tabelle vom Python3 Script als Linie\relax }}{21}{figure.caption.14}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {7.5}{\ignorespaces Sinus nach der Tabelle vom Python3 Script mit Stützpunkten\relax }}{22}{figure.caption.15}\protected@file@percent }
\BKM@entry{id=18,dest={636861707465722E38},srcline={429},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030455C3030306E5C303030745C303030775C303030695C303030635C3030306B5C3030306C5C303030755C3030306E5C303030675C303030735C303030755C3030306D5C303030675C303030655C303030625C303030755C3030306E5C30303067}
\@writefile{toc}{\contentsline {chapter}{\numberline {8}Entwicklungsumgebung}{23}{chapter.8}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\BKM@entry{id=19,dest={636861707465722A2E3136},srcline={455},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030545C303030615C303030625C303030655C3030306C5C3030306C5C303030655C3030306E}
\@writefile{toc}{\contentsline {chapter}{\nonumberline Tabellen}{25}{chapter*.16}\protected@file@percent }
\gdef\lot@l@number{47.7639pt}
\BKM@entry{id=20,dest={636861707465722A2E3137},srcline={456},srcfile={2E2E2F446F63756D656E74732F446F6B756D656E746174696F6E20424A2D4B657965722E746578}}{5C3337365C3337375C303030415C303030625C303030625C303030695C3030306C5C303030645C303030755C3030306E5C303030675C303030655C3030306E}
\@writefile{toc}{\contentsline {chapter}{\nonumberline Abbildungen}{27}{chapter*.17}\protected@file@percent }
\gdef\lof@l@number{49.59253pt}
\global\@namedef{scr@dte@chapter@lastmaxnumwidth}{10.40242pt}
\global\@namedef{scr@dte@section@lastmaxnumwidth}{18.37404pt}
\global\@namedef{scr@dte@subsection@lastmaxnumwidth}{26.89314pt}
\global\@namedef{scr@dte@table@lastmaxnumwidth}{46.66884pt}
\global\@namedef{scr@dte@figure@lastmaxnumwidth}{48.49747pt}
\@writefile{toc}{\providecommand\tocbasic@end@toc@file{}\tocbasic@end@toc@file}
\@writefile{lot}{\providecommand\tocbasic@end@toc@file{}\tocbasic@end@toc@file}
\@writefile{lof}{\providecommand\tocbasic@end@toc@file{}\tocbasic@end@toc@file}
\gdef \@abspage@last{27}

@ -0,0 +1,17 @@
\babel@toc {ngerman}{}
\addvspace {10\p@ }
\addvspace {10\p@ }
\addvspace {10\p@ }
\contentsline {figure}{\numberline {3.1}{\ignorespaces Diagramm Mode A\relax }}{9}{figure.caption.4}%
\contentsline {figure}{\numberline {3.2}{\ignorespaces Diagramm Mode B\relax }}{9}{figure.caption.5}%
\addvspace {10\p@ }
\addvspace {10\p@ }
\addvspace {10\p@ }
\addvspace {10\p@ }
\contentsline {figure}{\numberline {7.1}{\ignorespaces Pulswellenmodulation\relax }}{18}{figure.caption.8}%
\contentsline {figure}{\numberline {7.2}{\ignorespaces Symmetrisches Rechtecksignal an PB3\relax }}{19}{figure.caption.11}%
\contentsline {figure}{\numberline {7.3}{\ignorespaces PWM - Tastgrad - Sinus\relax }}{20}{figure.caption.12}%
\contentsline {figure}{\numberline {7.4}{\ignorespaces Sinus nach Tabelle vom Python3 Script als Linie\relax }}{21}{figure.caption.14}%
\contentsline {figure}{\numberline {7.5}{\ignorespaces Sinus nach der Tabelle vom Python3 Script mit Stützpunkten\relax }}{22}{figure.caption.15}%
\addvspace {10\p@ }
\providecommand \tocbasic@end@toc@file {}\tocbasic@end@toc@file

File diff suppressed because it is too large Load Diff

@ -0,0 +1,13 @@
\babel@toc {ngerman}{}
\addvspace {10\p@ }
\addvspace {10\p@ }
\addvspace {10\p@ }
\addvspace {10\p@ }
\addvspace {10\p@ }
\contentsline {table}{\numberline {5.1}{\ignorespaces Programmierpunkte Teil 1\relax }}{13}{table.caption.6}%
\addvspace {10\p@ }
\contentsline {table}{\numberline {6.1}{\ignorespaces Klemmenbelegung\relax }}{15}{table.caption.7}%
\addvspace {10\p@ }
\contentsline {table}{\numberline {7.1}{\ignorespaces OCR1A Werte für verschiedene Frequenzen des Mithörtons\relax }}{21}{table.caption.13}%
\addvspace {10\p@ }
\providecommand \tocbasic@end@toc@file {}\tocbasic@end@toc@file

Binary file not shown.

@ -0,0 +1,23 @@
\babel@toc {ngerman}{}
\contentsline {chapter}{\numberline {1}Funktionen}{5}{chapter.1}%
\contentsline {chapter}{\numberline {2}Hinweise zur Dokumentation}{7}{chapter.2}%
\contentsline {chapter}{\numberline {3}Grundlagen}{9}{chapter.3}%
\contentsline {section}{\numberline {3.1}Betriebsarten eines Morse-Keyers}{9}{section.3.1}%
\contentsline {subsection}{\numberline {3.1.1}Zeitverhalten}{9}{subsection.3.1.1}%
\contentsline {chapter}{\numberline {4}Bedienung}{11}{chapter.4}%
\contentsline {section}{\numberline {4.1}Tastaturbelegung}{11}{section.4.1}%
\contentsline {subsection}{\numberline {4.1.1}Übersicht}{11}{subsection.4.1.1}%
\contentsline {chapter}{\numberline {5}Schaltung}{13}{chapter.5}%
\contentsline {section}{\numberline {5.1}Beschreibung}{13}{section.5.1}%
\contentsline {chapter}{\numberline {6}Beschreibung der Hardware}{15}{chapter.6}%
\contentsline {chapter}{\numberline {7}Beschreibung der Software}{17}{chapter.7}%
\contentsline {section}{\numberline {7.1}Timer 1}{17}{section.7.1}%
\contentsline {subsection}{\numberline {7.1.1}Timer einstellen}{17}{subsection.7.1.1}%
\contentsline {section}{\numberline {7.2}Sinus Mithörton durch Pulsweitenmodulation}{17}{section.7.2}%
\contentsline {subsection}{\numberline {7.2.1}Grundlagen}{17}{subsection.7.2.1}%
\contentsline {subsubsection}{\nonumberline Pulsweitenmodulation}{18}{subsubsection*.10}%
\contentsline {subsection}{\numberline {7.2.2}Sinustabelle}{21}{subsection.7.2.2}%
\contentsline {chapter}{\numberline {8}Entwicklungsumgebung}{23}{chapter.8}%
\contentsline {chapter}{\nonumberline Tabellen}{25}{chapter*.16}%
\contentsline {chapter}{\nonumberline Abbildungen}{27}{chapter*.17}%
\providecommand \tocbasic@end@toc@file {}\tocbasic@end@toc@file

@ -8,7 +8,7 @@
#define F_CPU 16000000UL
#define PRESCALER 8
#define SINEWAVELENGTH 64
#define SINEWAVELENGTH 64
#define F_CPUPRESIN (F_CPU/(PRESCALER*SINEWAVELENGTH))
#define USART_BAUDRATE 9600
#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
@ -138,18 +138,39 @@ const char CLRSCR[] = "\033[2J";
#define CLEARLINE " "
// Sine wave table for PWM, 256 values
//const unsigned char sinewave[] PROGMEM = {
// 0x80,0x8d,0x99,0xa5,0xb1,0xbd,0xc8,0xd2,0xdb,0xe3,0xeb,0xf1,0xf6,0xfa,0xfd,0xff, // 16
// 0xff,0xfe,0xfc,0xf8,0xf4,0xee,0xe7,0xdf,0xd6,0xcd,0xc2,0xb7,0xab,0x9f,0x93,0x86, // 32
// 0x7a,0x6d,0x61,0x55,0x49,0x3e,0x33,0x2a,0x21,0x19,0x12,0x0c,0x08,0x04,0x02,0x01, // 48
// 0x01,0x03,0x06,0x0a,0x0f,0x15,0x1d,0x25,0x2e,0x38,0x43,0x4f,0x5b,0x67,0x73,0x80 // 64
//};
const unsigned char sinewave[] PROGMEM = {
0x80,0x8d,0x99,0xa5,0xb1,0xbd,0xc8,0xd2,0xdb,0xe3,0xeb,0xf1,0xf6,0xfa,0xfd,0xff, // 16
0xff,0xfe,0xfc,0xf8,0xf4,0xee,0xe7,0xdf,0xd6,0xcd,0xc2,0xb7,0xab,0x9f,0x93,0x86, // 32
0x7a,0x6d,0x61,0x55,0x49,0x3e,0x33,0x2a,0x21,0x19,0x12,0x0c,0x08,0x04,0x02,0x01, // 48
0x01,0x03,0x06,0x0a,0x0f,0x15,0x1d,0x25,0x2e,0x38,0x43,0x4f,0x5b,0x67,0x73,0x80 // 64
0x00, 0x01, 0x02, 0x05, 0x0a, 0x0f, 0x15, 0x1d, 0x25, 0x2f, 0x39, 0x43, 0x4f, 0x5a, 0x67, 0x73,
0x80, 0x8c, 0x98, 0xa5, 0xb0, 0xbc, 0xc6, 0xd0, 0xda, 0xe2, 0xea, 0xf0, 0xf5, 0xfa, 0xfd, 0xfe,
0xff, 0xfe, 0xfd, 0xfa, 0xf5, 0xf0, 0xea, 0xe2, 0xda, 0xd0, 0xc6, 0xbc, 0xb0, 0xa5, 0x98, 0x8c,
0x80, 0x73, 0x67, 0x5a, 0x4f, 0x43, 0x39, 0x2f, 0x25, 0x1d, 0x15, 0x0f, 0x0a, 0x05, 0x02, 0x01
};
//const unsigned char sinewave[] PROGMEM = {
//0 , 0 , 0 , 1 , 2 , 3 , 5 , 7 , 9 , 12 , 14 , 17 , 21 , 24 , 28 , 32,
//36 , 41 , 46 , 51 , 56 , 61 , 66 , 72 , 78 , 83 , 89 , 95 , 101 , 107 , 114 , 120,
//127 , 133 , 139 , 145 , 151 , 157 , 163 , 169 , 175 , 181 , 186 , 192 , 197 , 202 , 207 , 212,
//216 , 221 , 225 , 228 , 232 , 235 , 238 , 241 , 244 , 246 , 248 , 250 , 251 , 252 , 253 , 253,
//253 , 253 , 253 , 252 , 251 , 250 , 248 , 246 , 244 , 241 , 239 , 236 , 232 , 229 , 225 , 221,
//216 , 212 , 207 , 202 , 197 , 192 , 187 , 181 , 175 , 169 , 164 , 158 , 151 , 145 , 139 , 133,
//127 , 120 , 114 , 108 , 102 , 96 , 90 , 84 , 78 , 72 , 67 , 61 , 56 , 51 , 46 , 41,
//37 , 33 , 28 , 25 , 21 , 18 , 15 , 12 , 9 , 7 , 5 , 3 , 2 , 1 , 0 , 0
//};
uint8_t sdebug[64];
// Sidetone generation
double sidetone_f = 600;
volatile uint8_t icnt;
volatile uint8_t ocr2a;
// Diverse Zähler für Timer 0
uint16_t StoreEEprom = 0; // Wartezeit bis EEPROM geschrieben wird
@ -207,6 +228,8 @@ uint8_t DitCounter = 0;
uint8_t DahCounter = 0;
uint8_t CurrentTRX = TRX1;
uint8_t SpeedWpM = 1;
uint8_t StateRisetime = 0;
volatile uint8_t StateRisetimeCounter = 0;
volatile uint16_t l_timer = 0; // counter for LED on
volatile uint8_t t_timer = 0; // Frequency of audio output
@ -229,16 +252,17 @@ uint8_t ee_trx EEMEM = 0; // TRX 1 (0), TRX 2 (1), Beide (2)
struct Config
{
uint8_t trx;
uint8_t iambic;
uint8_t ratio;
uint16_t sidetone_f;
uint8_t sidetone;
uint8_t wpmbpm;
uint8_t wpm;
uint8_t reverse;
uint8_t weight;
uint8_t trx;
uint8_t iambic;
uint8_t ratio;
uint16_t sidetone_f;
uint8_t sidetone;
uint8_t wpmbpm;
uint8_t wpm;
uint8_t reverse;
uint8_t weight;
uint8_t Risetime;
uint8_t RisetimeCounter;
} bConfig;
// Function prototypes
void Init(void);

@ -99,6 +99,9 @@ uint8_t ReadKeyPin(uint8_t pin)
void SideToneOn(void)
{
state_sidetoneoff = 0;
StateRisetime = bConfig.Risetime;
StateRisetimeCounter = 0;
icnt = 0;
sbi(TIMSK1,OCIE1A);
}
/*
@ -107,7 +110,8 @@ void SideToneOn(void)
void SideToneOff(void)
{
state_sidetoneoff = 1;
cbi(TIMSK1,OCIE1A);
StateRisetime = 0;
StateRisetimeCounter = 0;
}
/*
** TXSidetoneKey
@ -119,6 +123,7 @@ void TXSidetoneKey(uint8_t State, uint8_t SendingType)
if(KeyTX)
{
SideToneOn();
PORTC |= (1<<MORSE_LED);
KeyState = 1;
}
}
@ -129,6 +134,7 @@ void TXSidetoneKey(uint8_t State, uint8_t SendingType)
if(KeyTX)
{
SideToneOff();
PORTC &= ~(1<<MORSE_LED);
}
KeyState = 0;
}

@ -101,6 +101,7 @@ void InitTimer(void)
// Initial value
OCR2A = 0x80;
sbi(DDRB,PB3);
cbi(TIMSK2,OCIE0A);
// Timer 1 für die Sinus Hüllkurve
TCCR1A = 0; TCCR1B = 0; TIMSK1 = 0;
@ -164,10 +165,10 @@ void Init()
// PD4 - StraightKey - PCINT20 - Pin Change Interrupt 20
// PD3 - Right Paddle - PCINT19 - Pin Change Interrupt 19
// PD2 - Left Paddle - PCINT18 - Pin Change Interrupt 18
sbi(PCICR,PCIE2);
sbi(PCMSK2,PCINT18);
sbi(PCMSK2,PCINT19);
sbi(PCMSK2,PCINT20);
// sbi(PCICR,PCIE2);
// sbi(PCMSK2,PCINT18);
// sbi(PCMSK2,PCINT19);
// sbi(PCMSK2,PCINT20);
// Init serial
UBRR0=UBRR_VALUE; // Set baud rate
@ -197,6 +198,8 @@ void Init()
bConfig.wpm = 15;
bConfig.ratio = 30;
bConfig.reverse = 0;
bConfig.Risetime = 4;
bConfig.RisetimeCounter = 4;
sei(); // enable all interrupts
}
/** \brief 16 Bit Timer 1A
@ -213,12 +216,41 @@ void Init()
//
ISR(TIMER1_COMPA_vect)
{
OCR2A = pgm_read_byte_near(sinewave+icnt);
ocr2a = pgm_read_byte_near(sinewave+icnt);
icnt++;
if(icnt > SINEWAVELENGTH - 1)
if(StateRisetime > 0)
OCR2A = (ocr2a >> StateRisetime);
else
OCR2A = ocr2a;
if(icnt == SINEWAVELENGTH)
{
icnt = 0;
if(state_sidetoneoff == 0)
{
if(StateRisetime > 0)
{
StateRisetimeCounter++;
if(StateRisetimeCounter > bConfig.RisetimeCounter)
StateRisetime--;
}
}
if(state_sidetoneoff == 1)
{
if(StateRisetime < bConfig.Risetime)
{
StateRisetimeCounter++;
if(StateRisetimeCounter > bConfig.RisetimeCounter)
StateRisetime++;
} else {
OCR2A = 0;
cbi(TIMSK1,OCIE1A);
}
}
}
}
/** \brief 8 Bit Timer 0
*
* The Timer 0 CTC interrupt
@ -287,35 +319,6 @@ ISR(TIMER2_OVF_vect)
}
/** \brief Pin Change Interupts für Paddle und StraightKey
*
* Pin Change Interrupt Vector für die Tasteneingänge
* Str Pa2 Pa1
* PORTD PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0
* x80 x40 x20 x10 x8 x4 x2 x1
*
*/
ISR(PCINT2_vect)
{
uint8_t changedbits;
changedbits = PIND ^ keyhistory;
keyhistory = PIND;
if(changedbits & (1<<STRAIGHT_KEY))
{
if(PIND & (1<<STRAIGHT_KEY))
{
PORTC &= ~(1<<MORSE_LED);
SideToneOff();
}
else
{
PORTC |= (1<<MORSE_LED);
SideToneOn();
}
}
}
ISR(USART_RX_vect)
{
unsigned char data;
@ -373,6 +376,7 @@ void CheckDahPaddle(void)
DahBuffer = 1;
}
}
/*
** DoMorse
*/
@ -670,8 +674,6 @@ int main(void)
{
Init();
SideToneOff();
lcd_init(LCD_DISP_ON);
lcd_charMode(DOUBLESIZE);
lcd_home();
@ -680,6 +682,7 @@ int main(void)
lcd_puts(VER);
lcd_gotoxy(2,4);
lcd_puts(CALL);
SideToneOff();
delayms(1000);
MachineMode = NORMAL;
@ -689,9 +692,7 @@ int main(void)
SendSerialString(CLRSCR);
SendSerialString("BJ-Keyer V1.00\r\n");
SendSerialString("Ready!\r\n");
EncoderWrite(bConfig.wpm);
BeepBoop();
SetFrequency(600);
@ -704,11 +705,12 @@ int main(void)
UpdateDisplay();
// if(MachineMode == NORMAL)
// {
// CheckPaddles();
// DoMorse();
// }
if(MachineMode == NORMAL)
{
CheckStraightKey();
CheckPaddles();
DoMorse();
}
if(MachineMode == COMMAND)
{

Loading…
Cancel
Save