From d0ae44ea324d067ec9b2ba6835449a1d6638b4a1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 8 Jul 2019 04:13:40 -0400 Subject: [PATCH 1/5] Testing change of RNG START bit test in ax5043_autoranging --- afsk/ax5043.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/afsk/ax5043.c b/afsk/ax5043.c index f74b4ad9..22d67e34 100644 --- a/afsk/ax5043.c +++ b/afsk/ax5043.c @@ -447,11 +447,10 @@ int ax5043_set_tx_freq(ax5043_conf_t *conf, uint32_t freq) { conf->tx_freq = freq; /* If the frequency difference is great enough perform autoranging */ -/* if (freq + 25000000 > prev_freq || freq - 25000000 < prev_freq) { ax5043_autoranging(conf); } -*/ + return PQWS_SUCCESS; } @@ -622,7 +621,7 @@ int ax5043_autoranging(ax5043_conf_t *conf) { usleep(10); val = 0; /* Wait until the autoranging is complete */ - while ((val & BIT(4)) == 0) { + while ((val & BIT(4)) == 1) { // changed to 1 from 0, since https://www.onsemi.com/pub/Collateral/AND9347-D.PDF says BIT(4) RNG START clears when autoranging done ret = ax5043_spi_read_8(conf, &val, pllranging_reg); if (ret) { return ret; From 02ff2ecb3239eef61ff43ad667c081b8c29b8fbe Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 8 Jul 2019 06:40:03 -0400 Subject: [PATCH 2/5] autoranging bug fix --- afsk/ax5043.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/ax5043.c b/afsk/ax5043.c index 22d67e34..a1902d58 100644 --- a/afsk/ax5043.c +++ b/afsk/ax5043.c @@ -619,9 +619,9 @@ int ax5043_autoranging(ax5043_conf_t *conf) { } usleep(10); - val = 0; + //val = 0; /* Wait until the autoranging is complete */ - while ((val & BIT(4)) == 1) { // changed to 1 from 0, since https://www.onsemi.com/pub/Collateral/AND9347-D.PDF says BIT(4) RNG START clears when autoranging done + while ((val & BIT(4)) != 0) { // changed to !=, since https://www.onsemi.com/pub/Collateral/AND9347-D.PDF says BIT(4) RNG START clears when autoranging done ret = ax5043_spi_read_8(conf, &val, pllranging_reg); if (ret) { return ret; From 2ae75ad8a7c91e95f3837ec40f69296e99fdf92d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 8 Jul 2019 07:09:41 -0400 Subject: [PATCH 3/5] autoranging with timeout --- afsk/ax5043.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/afsk/ax5043.c b/afsk/ax5043.c index a1902d58..b28223a4 100644 --- a/afsk/ax5043.c +++ b/afsk/ax5043.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "ax25.h" #include "ax5043.h" #include "status.h" @@ -621,14 +622,19 @@ int ax5043_autoranging(ax5043_conf_t *conf) { usleep(10); //val = 0; /* Wait until the autoranging is complete */ - while ((val & BIT(4)) != 0) { // changed to !=, since https://www.onsemi.com/pub/Collateral/AND9347-D.PDF says BIT(4) RNG START clears when autoranging done + int timeout = 0; + clock_t start = clock(); + while (((val & BIT(4)) != 0) && !timeout ) { // changed to !=, since https://www.onsemi.com/pub/Collateral/AND9347-D.PDF says BIT(4) RNG START clears when autoranging done ret = ax5043_spi_read_8(conf, &val, pllranging_reg); if (ret) { return ret; } + if ((clock() - start) > 500000) { + timeout = 1; + } } - if (val & BIT(5)) { + if ((val & BIT(5)) || timeout) { return -PQWS_AX5043_AUTORANGING_ERROR; } From 02133b00af5de198cba9d954a221d80fae6741c7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 8 Jul 2019 07:29:44 -0400 Subject: [PATCH 4/5] Update ax5043.c --- afsk/ax5043.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/afsk/ax5043.c b/afsk/ax5043.c index b28223a4..2bae28cc 100644 --- a/afsk/ax5043.c +++ b/afsk/ax5043.c @@ -616,6 +616,7 @@ int ax5043_autoranging(ax5043_conf_t *conf) { val = BIT(4) | AX5043_VCOR_INIT; ret = ax5043_spi_write_8(conf, pllranging_reg, val); if (ret) { + printf("ERROR: AX5043 Autoranging Write Failure\n\n"); return ret; } @@ -627,6 +628,7 @@ int ax5043_autoranging(ax5043_conf_t *conf) { while (((val & BIT(4)) != 0) && !timeout ) { // changed to !=, since https://www.onsemi.com/pub/Collateral/AND9347-D.PDF says BIT(4) RNG START clears when autoranging done ret = ax5043_spi_read_8(conf, &val, pllranging_reg); if (ret) { + printf("ERROR: AX5043 Autoranging Read Failure\n\n"); return ret; } if ((clock() - start) > 500000) { @@ -634,10 +636,13 @@ int ax5043_autoranging(ax5043_conf_t *conf) { } } - if ((val & BIT(5)) || timeout) { + if (val & BIT(5)) { + printf("ERROR: AX5043 Autoranging Error\n\n"); return -PQWS_AX5043_AUTORANGING_ERROR; + } else if (timeout) { + printf("ERROR: AX5043 Autoranging Timeout\n\n"); + return -1; } - return PQWS_SUCCESS; } From c0e3b9e70fc449bd398785006b987569e917d1c4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 8 Jul 2019 07:34:39 -0400 Subject: [PATCH 5/5] Autoranging error messages added --- afsk/ax5043.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/ax5043.c b/afsk/ax5043.c index 2bae28cc..8ed001f5 100644 --- a/afsk/ax5043.c +++ b/afsk/ax5043.c @@ -631,7 +631,7 @@ int ax5043_autoranging(ax5043_conf_t *conf) { printf("ERROR: AX5043 Autoranging Read Failure\n\n"); return ret; } - if ((clock() - start) > 500000) { + if ((clock() - start) > 1000000) { timeout = 1; } }