Example for AFSK sending (AX25 format) added. DDS updated to a slower clock rate again.

This commit is contained in:
Stephen Olesen 2015-07-01 20:30:49 -06:00
parent 5689393c11
commit 429e645ad2
3 changed files with 77 additions and 3 deletions

View File

@ -42,7 +42,8 @@ void DDS::start() {
// clock as the DDS.
TCCR1B = _BV(CS11) | _BV(WGM13) | _BV(WGM12);
TCCR1A = 0;
ICR1 = ((F_CPU / 8) / refclk) - 1;
//ICR1 = ((F_CPU / 8) / refclk) - 1;
ICR1 = ((F_CPU / 8) / 9600) - 1;
// Configure the ADC here to automatically run and be triggered off Timer1
ADMUX = _BV(REFS0) | _BV(ADLAR) | 0; // Channel 0, shift result left (ADCH used)

4
DDS.h
View File

@ -42,7 +42,7 @@
// This is how often we'll perform a phase advance, as well as ADC sampling
// rate. The higher this value, the smoother the output wave will be, at the
// expense of CPU time. It maxes out around 62000 (TBD)
#define DDS_REFCLK_DEFAULT 38400
#define DDS_REFCLK_DEFAULT 9600
// As each Arduino crystal is a little different, this can be fine tuned to
// provide more accurate frequencies. Adjustments in the range of hundreds
// is a good start.
@ -50,7 +50,7 @@
#ifdef DDS_USE_ONLY_TIMER2
// TODO: Figure out where this clock value is generated from
#define DDS_REFCLK_DEFAULT 48800
#define DDS_REFCLK_DEFAULT (62500/4)
#endif
// When defined, use the 1024 element sine lookup table. This improves phase

View File

@ -0,0 +1,73 @@
#include <HamShield.h>
#include <Wire.h>
HamShield radio;
DDS dds;
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(10, OUTPUT);
pinMode(3, OUTPUT);
pinMode(11, OUTPUT);
digitalWrite(2, LOW);
digitalWrite(10, LOW);
dds.start();
radio.afsk.start(&dds);
Serial.println("Starting...");
}
void loop() {
// put your main code here, to run repeatedly:
AFSK::Packet *packet = AFSK::PacketBuffer::makePacket(22 + 32);
packet->start();
packet->appendFCS('V'<<1);
packet->appendFCS('E'<<1);
packet->appendFCS('6'<<1);
packet->appendFCS('S'<<1);
packet->appendFCS('L'<<1);
packet->appendFCS('P'<<1);
packet->appendFCS(0b11100000);
packet->appendFCS('V'<<1);
packet->appendFCS('A'<<1);
packet->appendFCS('6'<<1);
packet->appendFCS('G'<<1);
packet->appendFCS('A'<<1);
packet->appendFCS(' '<<1);
packet->appendFCS(0b01100001 | (15 & 0xf) << 1);
packet->appendFCS(0x03);
packet->appendFCS(0xf0);
packet->print("Hello ");
packet->println(millis());
packet->finish();
bool ret = radio.afsk.putTXPacket(packet);
if(radio.afsk.txReady())
if(radio.afsk.txStart()) {
Serial.println("PTT here.");
}
// Wait 2 seconds before we send our beacon again.
Serial.println("tick");
delay(2000);
}
/*ISR(TIMER2_OVF_vect) {
TIFR2 = _BV(TOV2);
static uint8_t tcnt = 0;
if(++tcnt == 8) {
digitalWrite(2, HIGH);
dds.clockTick();
digitalWrite(2, LOW);
tcnt = 0;
}
}*/
ISR(ADC_vect) {
TIFR1 = _BV(ICF1); // Clear the timer flag
digitalWrite(2, HIGH);
dds.clockTick();
radio.afsk.timer();
digitalWrite(2, LOW);
}