dfannin / adf4351

Arduino library for the ADF4351 PLL Frequency Synthesizer chip
MIT License
44 stars 29 forks source link

Difficulty running with Adafruit Feather M4 Express #7

Open E63S4Me opened 3 years ago

E63S4Me commented 3 years ago

Somewhat of a noob at copying in libraries and other code beside the example sketches. I thought I had followed the instructions but am getting the errors below when I attempt to compile the example4351 sketch. Changed my username to xxxxx but other than that just copy/pasted the text from the Arduino IDE.

Any help would be greatly appreciated.

Arduino: 1.8.16 (Mac OS X), Board: "Adafruit Feather M4 Express (SAMD51), Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off"

/Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp: In constructor 'ADF4351::ADF4351(byte, uint8_t, long unsigned int, uint8_t)': /Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp:94:37: error: invalid conversion from 'uint8_t' {aka 'unsigned char'} to 'BitOrder' [-fpermissive] 94 spi_settings = SPISettings(speed, order, mode) ; ^~~~~
uint8_t {aka unsigned char}

In file included from /Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.h:12, from /Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp:51: /Users/xxxxx/Library/Arduino15/packages/adafruit/hardware/samd/1.7.5/libraries/SPI/SPI.h:66:40: note: initializing argument 2 of 'SPISettings::SPISettings(uint32_t, BitOrder, uint8_t)' 66 | SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) { | ~~~^~ /Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp: In member function 'int ADF4351::setf(uint32_t)': /Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp:156:3: error: 'dtostrf' was not declared in this scope 156 | dtostrf(PFDFreq, cntdigits + 8 , 3, tmpstr) ; | ^~~ exit status 1 Error compiling for board Adafruit Feather M4 Express (SAMD51).

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

dfannin commented 3 years ago

This library was developed on Arduino atmel based boards (Nano, Mega, etc), The Adafruit Feather M4 is a SAM51-based board, so I expect that you'll run into a number of issues. YMMV.

Issue 1:

On the first issue above, the SPI library function call SPISettings() is #declared differently for SAM51 boards. SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) <- SAM51

BitOrder is an enum declared in the adafruit/hardware/samd/1.7.5/cores/arduino/wiring_constants.h file and doesn't allow this to be converted to uint8_t (unsigned char) type.

What you can do is try changing:

file: adf4351.h, line 55: ADF4351(byte pin, uint8_t mode, unsigned long speed, uint8_t order ) ; to ADF4351(byte pin, uint8_t mode, unsigned long speed, BitOrder order ) ;

and file: adf4351.h, line 45: ADF4351::ADF4351(byte pin, uint8_t mode, unsigned long speed, uint8_t order ) { to ADF4351::ADF4351(byte pin, uint8_t mode, unsigned long speed, BitOrder order ) {

The Constants MSBFIRST and LSBFIRST are the same, so that should resolve this issue.

Issue 2:

For the dtostrf (double to string format) function call, that is also missing due to using this on SAM51, as this is included via the "avr/dtostrf.h" include, which is not added for non-AVR boards. Googling for this indicates that you can try adding it for SAM51 boards by adding the following include statement in adf4351.h.

#include <stdlib_noniso.h>

I don't have a way to test either of these, so if you get to work, let me know, and I'll update the library or send me a pull request.

E63S4Me commented 3 years ago

Thanks so much for the fast reply. I have a long day tomorrow so may not get a chance to try this till Tuesday, but will let you know how it goes.

I think I have a Mega board lying around, or at worst I know I have an Atmel based board that I can try.

Regards,

Daryl

Sent from my mobile device.

On Oct 17, 2021, at 8:53 PM, David Fannin @.***> wrote:

 This library was developed on Arduino atmel based boards (Nano, Mega, etc), The Adafruit Feather M4 is a SAM51-based board, so I expect that you'll run into a number of issues. YMMV.

Issue 1:

On the first issue above, the SPI library function call SPISettings() is #declared differently for SAM51 boards. SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) <- SAM51

BitOrder is an enum declared in the adafruit/hardware/samd/1.7.5/cores/arduino/wiring_constants.h file and doesn't allow this to be converted to uint8_t (unsigned char) type.

What you can do is try changing:

file: adf4351.h, line 55: ADF4351(byte pin, uint8_t mode, unsigned long speed, uint8_t order ) ; to ADF4351(byte pin, uint8_t mode, unsigned long speed, BitOrder order ) ;

and file: adf4351.h, line 45: ADF4351::ADF4351(byte pin, uint8_t mode, unsigned long speed, uint8_t order ) { to ADF4351::ADF4351(byte pin, uint8_t mode, unsigned long speed, BitOrder order ) {

The Constants MSBFIRST and LSBFIRST are the same, so that should resolve this issue.

Issue 2:

For the dtostrf (double to string format) function call, that is also missing due to using this on SAM51, as this is included via the "avr/dtostrf.h" include, which is not added for non-AVR boards. Googling for this indicates that you can try adding it for SAM51 boards by adding the following include statement in adf4351.h.

include

I don't have a way to test either of these, so if you get to work, let me know, and I'll update the library or send me a pull request.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

E63S4Me commented 3 years ago

Thanks, with those changes I was able to get the code to compile, except for the #include portion. The compiler wasn't finding it. Searching my computer for it didn't turn up anything so I went online and found a copy. Placed that in the Library directory with the ADF4351 code and pointed to that. After that it compiled OK and loads to the board with no problem.

I see the output on the serial port indicating that the code is running but I don't see anything out of the ADF4351 board. I am using the SV1AFN V2 ADF4351 module.

Not entirely sure I have the pinout correct on the Adafruit Feather M4 Express correctly mapped to the ADF4315 board however. The Feather board has the SCK, MO, and MI pins, which I take to be Clock, MOSI, and MISO, and I used pin 9 on the Feather for SS as indicated in the example file. But except for the clock (SPICLK) and data (SPIDAT) pins on the ADF4351 header it wasn't clear from the SV1AFN documentation how the other lines mapped - except for ground and +3 V of course.

Any additional thoughts welcome.