Jack Purdum
All: Anyone who is using interrupts might also want to avoid delay() as it is a blocking function. That is, if an interrupt event occurs during a delay() call, that interrupt cannot be serviced until the period used in delay() finishes. The millis() function is non-blocking, so you can build your own delay() function (e.g., myDelay()) if you want to. I don't think this is an issue with Allard's code because it does not use an ISR routines. Jack, W8TEE From: Allard PE1NWL <pe1nwl@...> To: [email protected] Sent: Saturday, April 29, 2017 2:10 PM Subject: Re: [BITX20] Birdie at 7.199 Thanks David, for your suggestion about avoiding the delay(). I'll try to include it in the next version. Also good to hear that you managed to (almost) eliminate the birdie with 8mA drive level. 73, Allard PE1NWL On Sat, April 29, 2017 19:53, David Fannin wrote: > Ok, so I tried the following si5351 drive levels (using 1.06 ): > > 2mA : ??loud @ 7.199 > > 4mA: loud @ 7.199 > > 6mA: loud @ 7.199 > > 8mA: very soft @ 7.199 > > I've left it at the 8mA level for now. ??Thanks, Allard for the software > and help.?? > > I'm not planning on increasing the software version yet, as I don't need > many of the features and would like things minimalist for now. ??I > modified 1.06 to change the frequency display from " A:07.1990 LSB " to " > 7.199.000 LSB ", as I wanted a more readable frequency display, and I > don't need VFO A/B or multiple bands. ??I also added a line to display my > call sign on setup. ??I also hardcoded the calibration setting, and > commented out the calibration and EEPROM code. ?? The code is fine, I just > chose to keep things simple for my radio. > > I did notice one item after reviewing the code (1.06). ?? There were a lot > of uses of delay() functions in the main loop (and in the doTuning() > function) . ??This will create a issue later on as you add more functions > to the code, as the code will be hanging on a delay, rather than > processing other items. ?? ??The usual solution is to use update > variables, and avoid using delays. ??Here's an example: > > existing: > > void loop() { > doTx(); > doTuning(); > delay(50); > }?? > > using update variables: > > unsigned long doTuningLastUpdate = 0 ; #define DOTUNINGTIMER ??(50UL)?? > > void loop(){ > checkTX(); > if ( ( millis() - doTuningLastUpdate ) > DOTUNINGTIMER ) { > ?? ?? doTuningLastUpdate = millis() ; > ?? ?? doTuning();?? > ?? }?? > > } > > The advantage is that the main loop runs continuously, while maintaining > the ability to run ??doTuning only ??every 50ms, without using delay() > functions. As you add more "simultaneous" features, you'll see the clear > benefit.?? > > thanks, > ?? > > Dave KK6DF > |