Please help!!! STM32F4 +RF24 library problem

Limited support for STM32F4 Discovery, Nucleo and custom F4 boards
41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Postby 41300895 » Thu Nov 24, 2016 6:24 pm

Manny wrote:This is what radio.printdetails outputs on my STM32F1

Code: Select all

STATUS = 0x0E RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1   = 0xCC 0xCC 0xCC 0x3C 0xCC 0xCC 0xCC 0xCC 0x3C 0x3C
RX_ADDR_P2-5   = 0x33 0xCE 0x3E 0xE3
TX_ADDR      = 0xE7 0xE7 0xE7 0xE7 0xE7
RX_PW_P0-6   = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA      = 0x3E
EN_RXADDR   = 0x3F
RF_CH      = 0x3C
RF_SETUP   = 0x27
CONFIG      = 0x0F
DYNPD/FEATURE   = 0x3F 0x04
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX


Can you implement the same thing with STM32F4 board?

User avatar
Manny
Posts: 29
Joined: Wed Dec 09, 2015 3:15 pm

Re: Please help!!! STM32F4 +RF24 library problem

Postby Manny » Fri Nov 25, 2016 7:02 am

Can you implement the same thing with STM32F4 board


Sorry don't have a F4 to try out.

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Postby 41300895 » Fri Nov 25, 2016 6:31 pm

so sad to here that, anyone can help me? I've been struggling with this for days and I'm rather desperate right now :?

zmemw16
Posts: 924
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Please help!!! STM32F4 +RF24 library problem

Postby zmemw16 » Fri Nov 25, 2016 11:35 pm

i don't understand why you've done or need to do this
+ I used the SPI library from here : https://github.com/rogerclarkmelbourne/Arduino_STM32 (in STM32F4/libraries/SPI) - I cut and paste it in the path: C:\Users\ASUS\Documents\Arduino\libraries\


it shouldn't be looking there at all, is there a quirk with f4 spi?

stephen

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Postby 41300895 » Sat Nov 26, 2016 3:49 am

i did it because if i left the spi folder in side stm32f4 directory, it couldn't compile if i add the line #include "SPI.h"

zmemw16
Posts: 924
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Please help!!! STM32F4 +RF24 library problem

Postby zmemw16 » Sat Nov 26, 2016 5:41 am

compiling for Discover F407, simple blink on pb6/pb7 with just an added include SPI.h
it at first flagged missing library maintainer, add fred also added abc@x.y.uk for the email
thought i'd add it in, did, tried re-compile, same of course (i knew that honest :)), restarted

then it gave up with

Code: Select all

In file included from /home/stephen/sketchbook/Blinki2c/Blinki2c.ino:19:0:
/home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/libraries/SPI/src/SPI.h:362:17: error: conflicting declaration 'SPIClass SPI'
 extern SPIClass SPI;//(1);// dummy params
                 ^
In file included from /home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/cores/maple/wirish.h:49:0,
                 from /home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/cores/maple/WProgram.h:27,
                 from /home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/cores/maple/Arduino.h:3,
                 from /tmp/arduino_build_22323/sketch/Blinki2c.ino.cpp:1:
/home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/cores/maple/libmaple/HardwareSPI.h:276:20: error: 'SPI' has a previous declaration as 'HardwareSPI SPI'
 extern HardwareSPI SPI;
                    ^
Using library SPI at version 1.0 in folder: /home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/libraries/SPI
exit status 1
Error compiling for board STM32 Discovery F407.


i don't know the cure for this

Arduino_STM32 directory is dated 20/11/16 and it would be the master branch as a zip

stephen

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Postby 41300895 » Sat Nov 26, 2016 9:56 am

I did have an exact error like you but I used method in this thread and I bypassed that error!
viewtopic.php?f=3&t=816&p=9227&hilit=extern+HardwareSPI#p9227

Just simply comment out the line extern HardwareSPI ... in your HardwareSPI.h file. If I recall correctly, this file is under ...\STM32F4\cores\maple\libmaple

stevestrong
Posts: 684
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Please help!!! STM32F4 +RF24 library problem

Postby stevestrong » Sat Nov 26, 2016 12:04 pm

41300895 wrote:i did it because if i left the spi folder in side stm32f4 directory, it couldn't compile if i add the line #include "SPI.h"

It should compile being in the default directory, if you have selected the right MCU as target.
If not, please post here the compile errors.

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Postby 41300895 » Sun Nov 27, 2016 2:36 am

stevestrong wrote:
41300895 wrote:i did it because if i left the spi folder in side stm32f4 directory, it couldn't compile if i add the line #include "SPI.h"

It should compile being in the default directory, if you have selected the right MCU as target.
If not, please post here the compile errors.

I selected Tools => STM32 Discovery F407
Under the path: ..Arduino\hardware\Arduino_STM32...\STM32F4\libraries (this is the default directory of STM32F4 when I unzip the zip file) I have libraries needed for my project:
SPI ( this file was originally there when I unzip Arduino_STM32.zip from GitHub)
STM32-nRF24l01_Sensor_RX ( include RF24.h, RF24_config.h, RF24.cpp, nRF24l01.h)
RF24Network-master (from maniacbug - GitHub)
DHT-sensor-libraries master (include DHT.h and DHT.cpp)
===============================================
If I include:

Code: Select all

#include<RF24.h>
#include <SPI.h>

or

Code: Select all

#include<RF24.h>
#include <C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\SPI\src\SPI.h>

=> the same error:

Code: Select all

Arduino: 1.6.12 (Windows 10), Board: "STM32 Discovery F407"

In file included from C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:10:0:

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'void RF24::csn(bool)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:42:3: note: in expansion of macro '_SPI'

   _SPI.setBitOrder(MSBFIRST);

   ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:45:24: error: 'SPI_CLOCK_DIV4' was not declared in this scope

   _SPI.setClockDivider(SPI_CLOCK_DIV4);

                        ^

In file included from C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:10:0:

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'uint8_t RF24::read_register(uint8_t, uint8_t*, uint8_t)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:115:12: note: in expansion of macro '_SPI'

   status = _SPI.transfer( R_REGISTER | ( REGISTER_MASK & reg ) );

            ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'uint8_t RF24::read_register(uint8_t)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:147:3: note: in expansion of macro '_SPI'

   _SPI.transfer( R_REGISTER | ( REGISTER_MASK & reg ) );

   ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'uint8_t RF24::write_register(uint8_t, const uint8_t*, uint8_t)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:179:12: note: in expansion of macro '_SPI'

   status = _SPI.transfer( W_REGISTER | ( REGISTER_MASK & reg ) );

            ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'uint8_t RF24::write_register(uint8_t, uint8_t)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:210:12: note: in expansion of macro '_SPI'

   status = _SPI.transfer( W_REGISTER | ( REGISTER_MASK & reg ) );

            ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'uint8_t RF24::write_payload(const void*, uint8_t, uint8_t)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:252:12: note: in expansion of macro '_SPI'

   status = _SPI.transfer( writeType );

            ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'uint8_t RF24::read_payload(void*, uint8_t)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:305:12: note: in expansion of macro '_SPI'

   status = _SPI.transfer( R_RX_PAYLOAD );

            ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'uint8_t RF24::spiTrans(uint8_t)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:345:12: note: in expansion of macro '_SPI'

   status = _SPI.transfer( cmd );

            ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'bool RF24::begin()':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:635:5: note: in expansion of macro '_SPI'

     _SPI.begin();

     ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'uint8_t RF24::getDynamicPayloadSize()':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:1059:3: note: in expansion of macro '_SPI'

   _SPI.transfer( R_RX_PL_WID );

   ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'void RF24::toggle_features()':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:1245:2: note: in expansion of macro '_SPI'

  _SPI.transfer( ACTIVATE );

  ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp: In member function 'void RF24::writeAckPayload(uint8_t, const void*, uint8_t)':

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24_config.h:98:16: error: 'SPI' was not declared in this scope

   #define _SPI SPI

                ^

C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.cpp:1329:3: note: in expansion of macro '_SPI'

   _SPI.transfer(W_ACK_PAYLOAD | ( pipe & 0b111 ) );

   ^

exit status 1
Error compiling for board STM32 Discovery F407.


If I include:

Code: Select all

#include<C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.h>
#include <C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\SPI\src\SPI.h>

or

Code: Select all

#include<C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.h>
#include <SPI.h>

=> Successfully compiled
But the second case (just merely #include<SPI.h>) => there is an error when I use SPIClass MySPI(3) command:

Code: Select all

#include<C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\STM32-nRF24L01_Sensor_RX\RF24.h>
#include <SPI.h>
SPIClass MySPI(3);

=> Error:

Code: Select all

Arduino: 1.6.12 (Windows 10), Board: "STM32 Discovery F407"

test:3: error: 'SPIClass' does not name a type

 SPIClass MySPI(3);

 ^

exit status 1
'SPIClass' does not name a type


Whereas the first case it produces no error at all
So I think I must specify the full path for each line #include
The problem is even I can compile without no error, the program still do not run, as you can see, the radio.printDetails output was absolutely nonsense

User avatar
Manny
Posts: 29
Joined: Wed Dec 09, 2015 3:15 pm

Re: Please help!!! STM32F4 +RF24 library problem

Postby Manny » Sun Nov 27, 2016 11:57 am

Try the library attached, I hacked it so the the SPIclass is defined in line 13 of RF24_STM32.cpp, I find it easier to do that way, you just got to remember to change the class if you're using different SPI pins.

Comment out all the SPI code in your sketch you just need to #include <SPI.h> and SPI.begin() in set up.

Another thing I noticed is you're using SPIClass(3) which on the STM32F1 that I'm using shares the pins with JTAG debug, to get round this you will need to put disableDebugPorts() in setup. Not sure if this effects the F4 but it wouldn't hurt to try it.

Code: Select all

disableDebugPorts();
Attachments
RF24_STM32.zip
(37.73 KiB) Downloaded 11 times


Return to “STM32F4 Boards”

Who is online

Users browsing this forum: No registered users and 1 guest