From 26ffcd332b7e279ef7247b9ba0eb6207f9dcd90c Mon Sep 17 00:00:00 2001 From: Stephen Olesen Date: Thu, 2 Jul 2015 19:58:54 -0600 Subject: [PATCH] Faster reference clock rate (using pin 3), skip outer loop to slow PSK. --- examples/PSK31-Transmit/PSK31-Transmit.ino | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/PSK31-Transmit/PSK31-Transmit.ino b/examples/PSK31-Transmit/PSK31-Transmit.ino index a71f9c1..70fbc03 100644 --- a/examples/PSK31-Transmit/PSK31-Transmit.ino +++ b/examples/PSK31-Transmit/PSK31-Transmit.ino @@ -5,10 +5,10 @@ DDS dds; void setup() { Serial.begin(9600); - pinMode(11, OUTPUT); + pinMode(3, OUTPUT); pinMode(2, OUTPUT); // put your setup code here, to run once: - dds.setReferenceClock(8000); + dds.setReferenceClock(32000); dds.start(); dds.setFrequency(1000); dds.on(); @@ -41,7 +41,7 @@ void loop() { // return; for(i = 0; i < strlen(string); i++) { sendChar(string[i]); - Serial.println(string[i]); + //Serial.println(string[i]); } } @@ -51,19 +51,25 @@ const uint8_t amplitudeShape[41] = { // This will trigger at 8kHz ISR(ADC_vect) { + static uint8_t outer = 0; static uint8_t tcnt = 0; TIFR1 |= _BV(ICF1); // Wave shaping - PORTD |= _BV(2); // TODO: Improve how this would perform. - if(tcnt < 82) - dds.setAmplitude(amplitudeShape[(82-tcnt)/2]); - if(tcnt > (255-82)) - dds.setAmplitude(amplitudeShape[(tcnt-173)/2]); //else if(tcnt > (255-64)) // dds.setAmplitude((255 - tcnt)); //else dds.setAmplitude(255); + if(tcnt < 81) + dds.setAmplitude(amplitudeShape[(81-tcnt)/2]); + if(tcnt > (255-81)) + dds.setAmplitude(amplitudeShape[(tcnt-174)/2]); dds.clockTick(); + PORTD &= ~_BV(2); + if(outer++ == 3) { + outer = 0; + } else { + return; + } if(tcnt++ == 0) { // Next bit //PORTD ^= _BV(2); // Diagnostic pin (D2) if(!sent) {