-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
it is working up to ~30.5M freq. so far no tight tests though.
- Loading branch information
Showing
5 changed files
with
203 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Roman Piksaykin [[email protected]], R2BDY | ||
// https://www.qrz.com/db/r2bdy | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// | ||
// dco2.pio Digital controlled radio freq oscillator based on PIO. | ||
// | ||
// | ||
// DESCRIPTION | ||
// - | ||
// | ||
// PLATFORM | ||
// Raspberry Pi pico. | ||
// | ||
// REVISION HISTORY | ||
// | ||
// Rev 2.0 09 Dec 2023 | ||
// New algo devising. | ||
// | ||
// LICENCE | ||
// MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
// | ||
// Copyright (c) 2023 by Roman Piksaykin | ||
// | ||
// Permission is hereby granted, free of charge,to any person obtaining a copy | ||
// of this software and associated documentation files (the Software), to deal | ||
// in the Software without restriction,including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY,WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
/////////////////////////////////////////////////////////////////////////////// | ||
.program dco | ||
|
||
.wrap_target | ||
out y, 32 | ||
mov x, y | ||
LOOP0: | ||
jmp x-- LOOP0 | ||
set pins, 1 | ||
|
||
mov x, y [1] | ||
LOOP1: | ||
jmp x-- LOOP1 | ||
set pins, 0 | ||
|
||
mov x, y [1] | ||
LOOP2: | ||
jmp x-- LOOP2 | ||
set pins, 1 | ||
|
||
mov x, y [1] | ||
LOOP3: | ||
jmp x-- LOOP3 | ||
set pins, 0 | ||
.wrap | ||
|
||
/* | ||
// it is OK for ~20.5M | ||
.wrap_target | ||
out y, 32 | ||
mov x, y | ||
LOOP0: | ||
jmp x-- LOOP0 | ||
set pins, 1 | ||
|
||
mov x, y [1] | ||
LOOP1: | ||
jmp x-- LOOP1 | ||
set pins, 0 | ||
.wrap | ||
*/ | ||
/* | ||
.wrap_target | ||
// CYCLES COUNT | ||
out y, 8 // 1. | ||
LOOP0: | ||
jmp y-- LOOP0 // 2 + y0. | ||
set pins, 1 // 1 * PI 3 + y0. | ||
|
||
out y, 8 // 4 + y0. | ||
LOOP1: | ||
jmp y-- LOOP1 // 5 + y0 + y1. | ||
set pins, 0 // 2 * PI 6 + y0 + y1. | ||
// 6 cycles min.=> 270MHz / 6 = 45MHz (VHF low-band). | ||
// 3rd harmonic is 135M. | ||
// 5th is 225M. | ||
// 7th is 315M. | ||
.wrap | ||
*/ | ||
|
||
% c-sdk { | ||
|
||
#define PIOASM_DELAY_CYCLES 4 | ||
|
||
static inline void dco_program_init(PIO pio, uint sm, uint offset, uint pin) | ||
{ | ||
pio_sm_config c = dco_program_get_default_config(offset); | ||
|
||
sm_config_set_out_shift(&c, true, true, 32); // Autopull. | ||
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); | ||
|
||
sm_config_set_out_pins(&c, pin, 1); | ||
pio_gpio_init(pio, pin); | ||
|
||
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true); | ||
|
||
sm_config_set_clkdiv_int_frac(&c, 1u, 0u); | ||
|
||
pio_sm_init(pio, sm, offset, &c); | ||
pio_sm_set_enabled(pio, sm, true); | ||
} | ||
// | ||
static inline void dco_program_puts(PIO pio, uint sm, const uint32_t *s) | ||
{ | ||
pio_sm_put_blocking(pio, sm, s[0]); | ||
pio_sm_put_blocking(pio, sm, s[1]); | ||
pio_sm_put_blocking(pio, sm, s[2]); | ||
pio_sm_put_blocking(pio, sm, s[3]); | ||
pio_sm_put_blocking(pio, sm, s[4]); | ||
pio_sm_put_blocking(pio, sm, s[5]); | ||
pio_sm_put_blocking(pio, sm, s[6]); | ||
pio_sm_put_blocking(pio, sm, s[7]); | ||
} | ||
|
||
static inline void dco_program_puts1w(PIO pio, uint sm, const uint32_t val) | ||
{ | ||
pio_sm_put_blocking(pio, sm, val); | ||
} | ||
%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters