Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. thom4s
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    thom4s

    @thom4s

    2
    Reputation
    4
    Posts
    118
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    thom4s Follow

    Best posts made by thom4s

    • RE: [SOLVED] STM32F103C8T6 bluepill clone - RFM69HW SPI port 1 and ILI9341 SPI port 2 not working together

      I will answer to myself. Problem were in wrong definition of IRQ pin in sketch. But, as I found out STM32F103C8T6 has SPI 1 running on 72MHz (for SPI max 72/2 = 36MHz) and SPI 2 36MHz (for SPI max 36/2 = 18MHz) so it were a stupid idea to wire TFT display to SPI 2 port which is slower than SPI 1 with RFM69HW which doesnt need so fast SPI. Therefore I switched radio to SPI-2 and TFT display to faster SPI-1.

      Radio SPI-2 and TFT ILI9341 SPI-1 wiring

      // RFM69HW radio on SPI-2 
      //
      // CS / NSS   - PB12
      // DI00 / IRQ - PA8
      // SCK        - PB13
      // MISO       - PB14
      // MOSI       - PB15
      
      // TFT DISPLAY ili9341 on SPI-1
      //
      // CS         - PA4
      // RESET /RST - PA2
      // DC / RS    - PA3
      // SCK        - PA5
      // MISO       - PA6
      // MOSI       - PA7
      

      Add to sketch before #include <MySensors.h>

      #define MY_RFM69_NEW_DRIVER
      #define MY_RFM69_IRQ_PIN PA8
      #define MY_RFM69_IRQ_NUM PA8
      #define MY_RFM69_CS_PIN PB12
      #define MY_RFM69_STM32F103_SPI2
      //#define MY_RFM69_SPI_SPEED (18*1000000ul) //When SPI-2 speed needs to be reduced
      
      //Possible speeds on SPI 2 for RFM69HW:
      //
      //SPI_CLOCK_DIV2 = 36 / 2 = 18 MHz
      //SPI_CLOCK_DIV4 = 36 / 4 = 9 MHz
      //SPI_CLOCK_DIV8 = 36 / 8 = 4.5 MHz
      //SPI_CLOCK_DIV16 = 36 / 16 = 2.25 MHz
      //SPI_CLOCK_DIV32 = 36 / 32 = 1.125 MHz
      

      As you can see there is a new defined parameter MY_RFM69_STM32F103_SPI2 so if we want to use SPI 2 then modification of RFM69_new.h is needed.

      Edit file: MySensors-master/hal/transport/RFM69/driver/new/RFM69_new.h

      Add following lines after line 112 (after #include <SPI.h>)

      #if defined(MY_RFM69_STM32F103_SPI2)
      SPIClass SPI_2(2);
      #define RFM69_SPI SPI_2
      #endif

      Modified RFM69_new.h should looks like:

      #if defined(ARDUINO) && !defined(__arm__) && !defined(RFM69_SPI)
      #include <SPI.h>
      #if defined(MY_SOFTSPI)
      SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, RFM69_SPI_DATA_MODE>RFM69_SPI;
      #else
      #define RFM69_SPI SPI
      #endif
      #else
      #if defined(__arm__) || defined(__linux__)
      #include <SPI.h>
      #if defined(MY_RFM69_STM32F103_SPI2)  //!<  ADD THIS AFTER LINE 112
      SPIClass  SPI_2(2);                   //!<  ADD THIS AFTER LINE 112
      #define RFM69_SPI SPI_2               //!<  ADD THIS AFTER LINE 112
      #endif                                //!<  ADD THIS AFTER LINE 112
      #else
      extern HardwareSPI SPI;		//!< SPI
      #endif
      #if !defined(RFM69_SPI)
      #define RFM69_SPI SPI		//!< SPI
      #endif
      #endif
      
      posted in Hardware
      thom4s
      thom4s

    Latest posts made by thom4s

    • RE: STM32F411 BlackpillV2 ST core - problem with reading data from RS485 (HW serial 2)

      OK problem found. Found out that when I selected "Blackpill F411CE" board before code compilation everything were ok.
      Usually I am choosing generic types so I used "F411CEUx" in case of blackpill 2 and I found out that generic types has different default "Serial" pins in ST core. Now I can confirm that Bluepill , Blackpill and F4VE board are working with MAX485.

      ST core v 2.4.0.

      ../.arduino15/packages/STMicroelectronics/hardware/stm32/2.4.0/variants/STM32F4xx/F411C(C-E)(U-Y)/variant_generic.h

      // UART Definitions
      #ifndef SERIAL_UART_INSTANCE
        #define SERIAL_UART_INSTANCE  2
      #endif
      
      // Default pin used for generic 'Serial' instance
      // Mandatory for Firmata
      #ifndef PIN_SERIAL_RX
        #define PIN_SERIAL_RX         PA3
      #endif
      #ifndef PIN_SERIAL_TX
        #define PIN_SERIAL_TX         PA2
      #endif
      

      ../.arduino15/packages/STMicroelectronics/hardware/stm32/2.4.0/variants/STM32F4xx/F411C(C-E)(U-Y)/variant_BLACKPILL_F411CE.h

      // UART Definitions
      #ifndef SERIAL_UART_INSTANCE
        #define SERIAL_UART_INSTANCE  1
      #endif
      
      // Default pin used for generic 'Serial' instance
      // Mandatory for Firmata
      #ifndef PIN_SERIAL_RX
        #define PIN_SERIAL_RX         PA10
      #endif
      #ifndef PIN_SERIAL_TX
        #define PIN_SERIAL_TX         PA9
      #endif
      

      So be carefull while using ST core and generic type of STM32.

      posted in Troubleshooting
      thom4s
      thom4s
    • STM32F411 BlackpillV2 ST core - problem with reading data from RS485 (HW serial 2)

      Hi,
      for years Im using MySensors 2.3.1 lib running on Bluepill (STM32F103C8T6 Roger`s STM32 core) with RS485 transport as a node without any problems. Now I need to add new node so I decided to use BlackPill 2 (STM32F411) with STM32 ST core and Whisky Delta fork . (https://github.com/WhiskyDelta/MySensors/tree/stm32_cores) I have no problem with code compilation of simple test node sketch but node is not receiving data from gateway through RS485.

      As you can see from debug log, node send a message and GW replied but node does not received anything. Strange thing is that some chars appeared in debug console "�vXvv���" before 2215 ?TSF:MSG:SEND,.....

      For testing purpose Iv got on desk Ardu Nano as GW with MAX485 converters and as a node I tested with Whisky Delta lib one by one Arduino Mega2560 , Bluepill STM32F103c8t6 , Blackpill2 STM32F411 and F4VE (STM32F407VET). As a node is working only Mega2560. Bluepill were frozen after first attempt to pair with GW. Blackpill 2 and F4VE are repeating sending request for pair to GW with this strange chars in serial debug. ("�vXvv���")

      Im sure that HW is ok. (wiring,DE+RE,termination resistors,5V supply of MAX485, etc)

      Does anybody else has a problem like this ? Do you have any idea where should be a problem ?

      Gateway received data from node and responded

      0;255;3;0;9;8233171 TSF:MSG:READ,118-118-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
      0;255;3;0;9;8233177 TSF:MSG:BC
      0;255;3;0;9;8233180 TSF:MSG:FPAR REQ,ID=118
      0;255;3;0;9;8233184 TSF:PNG:SEND,TO=0
      0;255;3;0;9;8233187 TSF:CKU:OK
      0;255;3;0;9;8233190 TSF:MSG:GWL OK
      0;255;3;0;9;8233447 TSF:MSG:SEND,0-0-118-118,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
      

      Node trying to pair but does not receive data from gateway. What are chars �vXvv��� ?

      2050 MCO:BGN:INIT OK,TSP=0
      2211 !TSM:FPAR:NO REPLY
      2213 TSM:FPAR
      �vXvv���2215 ?TSF:MSG:SEND,118-118-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0
      
      

      Simple node sketch. Debug is using Serial1 and MAX485 is using Serial2

      #define MY_DEBUG                          
      
      #define MY_TRANSPORT_WAIT_READY_MS 2000  
      
      //#define MY_TRANSPORT_SANITY_CHECK
      //#define MY_TRANSPORT_SANITY_CHECK_INTERVAL 2000 
      //#define MY_RS485_SOH_COUNT 2
      
      #define MY_NODE_ID 118
      
      #define MY_RS485
      #define MY_RS485_DE_PIN PB3
      
      #define MY_RS485_HWSERIAL Serial2
      
      #define MY_RS485_BAUD_RATE 9600
      
      
      #include <MySensors.h>
      
      #define CHILD_ID_SudyNode 0
      
      MyMessage msgStatus(CHILD_ID_SudyNode, V_VAR1); //Status
      MyMessage msgErrorEvent(CHILD_ID_SudyNode, V_VAR2); //Err event
      MyMessage msgDebug(CHILD_ID_SudyNode, V_VAR3); //DEBUG
      
      
      void presentation() {  sendSketchInfo("TestNODE", "Ver. 1");present(CHILD_ID_SudyNode, S_CUSTOM);}
      
      
      void setup() {
      
           Serial.setRx(PA10);
           Serial.setTx(PA9);
           Serial.begin(115200);  
      
      }
      
      String SendBuffer = "TEST Message";
      unsigned long CasovacMillis = millis();
      
      void loop() {
      
      
      if ((millis() - CasovacMillis) >= 3000) { 
       Serial.println("NODE ALIVE");
       send(msgStatus.set(SendBuffer.c_str()));
       CasovacMillis = millis();
      }
      
      }
      void receive(const MyMessage &message) {
                              
        if (message.sensor == 123 ) {
            String BufferString = message.getString();
            char CommandBuffer[BufferString.length()];
            BufferString.toCharArray(CommandBuffer, BufferString.length()+1); 
            Serial.print("RECEIVED DATA: "); Serial.println(CommandBuffer);
      }
      }
      
      posted in Troubleshooting
      thom4s
      thom4s
    • RE: [SOLVED] STM32F103C8T6 bluepill clone - RFM69HW SPI port 1 and ILI9341 SPI port 2 not working together

      I will answer to myself. Problem were in wrong definition of IRQ pin in sketch. But, as I found out STM32F103C8T6 has SPI 1 running on 72MHz (for SPI max 72/2 = 36MHz) and SPI 2 36MHz (for SPI max 36/2 = 18MHz) so it were a stupid idea to wire TFT display to SPI 2 port which is slower than SPI 1 with RFM69HW which doesnt need so fast SPI. Therefore I switched radio to SPI-2 and TFT display to faster SPI-1.

      Radio SPI-2 and TFT ILI9341 SPI-1 wiring

      // RFM69HW radio on SPI-2 
      //
      // CS / NSS   - PB12
      // DI00 / IRQ - PA8
      // SCK        - PB13
      // MISO       - PB14
      // MOSI       - PB15
      
      // TFT DISPLAY ili9341 on SPI-1
      //
      // CS         - PA4
      // RESET /RST - PA2
      // DC / RS    - PA3
      // SCK        - PA5
      // MISO       - PA6
      // MOSI       - PA7
      

      Add to sketch before #include <MySensors.h>

      #define MY_RFM69_NEW_DRIVER
      #define MY_RFM69_IRQ_PIN PA8
      #define MY_RFM69_IRQ_NUM PA8
      #define MY_RFM69_CS_PIN PB12
      #define MY_RFM69_STM32F103_SPI2
      //#define MY_RFM69_SPI_SPEED (18*1000000ul) //When SPI-2 speed needs to be reduced
      
      //Possible speeds on SPI 2 for RFM69HW:
      //
      //SPI_CLOCK_DIV2 = 36 / 2 = 18 MHz
      //SPI_CLOCK_DIV4 = 36 / 4 = 9 MHz
      //SPI_CLOCK_DIV8 = 36 / 8 = 4.5 MHz
      //SPI_CLOCK_DIV16 = 36 / 16 = 2.25 MHz
      //SPI_CLOCK_DIV32 = 36 / 32 = 1.125 MHz
      

      As you can see there is a new defined parameter MY_RFM69_STM32F103_SPI2 so if we want to use SPI 2 then modification of RFM69_new.h is needed.

      Edit file: MySensors-master/hal/transport/RFM69/driver/new/RFM69_new.h

      Add following lines after line 112 (after #include <SPI.h>)

      #if defined(MY_RFM69_STM32F103_SPI2)
      SPIClass SPI_2(2);
      #define RFM69_SPI SPI_2
      #endif

      Modified RFM69_new.h should looks like:

      #if defined(ARDUINO) && !defined(__arm__) && !defined(RFM69_SPI)
      #include <SPI.h>
      #if defined(MY_SOFTSPI)
      SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, RFM69_SPI_DATA_MODE>RFM69_SPI;
      #else
      #define RFM69_SPI SPI
      #endif
      #else
      #if defined(__arm__) || defined(__linux__)
      #include <SPI.h>
      #if defined(MY_RFM69_STM32F103_SPI2)  //!<  ADD THIS AFTER LINE 112
      SPIClass  SPI_2(2);                   //!<  ADD THIS AFTER LINE 112
      #define RFM69_SPI SPI_2               //!<  ADD THIS AFTER LINE 112
      #endif                                //!<  ADD THIS AFTER LINE 112
      #else
      extern HardwareSPI SPI;		//!< SPI
      #endif
      #if !defined(RFM69_SPI)
      #define RFM69_SPI SPI		//!< SPI
      #endif
      #endif
      
      posted in Hardware
      thom4s
      thom4s
    • [SOLVED] STM32F103C8T6 bluepill clone - RFM69HW SPI port 1 and ILI9341 SPI port 2 not working together

      Hi, I am using STM32F103C8T6 board with Arduino IDE 1.8.9 , library MySensors-2.3.1 and newest Arduino_STM32-master ILI9341_STM , bootloader generic_boot20_pc13.bin. I have a problem with using together RFM69HW on SPI-1 and TFT 2.2" ILI9341 display on SPI-2. TFT is working fine but RFM69HW radio stopped working after tft.begin(). Radio is working without problem on SPI1 when TFT on SPI2 is not initialized. Do you have any idea where should be a problem ?

      HW connection

      // RFM69HW radio on SPI-1 
      //
      // CS / NSS   - PA4
      // DI00 / IRQ - PA3
      // SCK        - PA5
      // MISO       - PA6
      // MOSI       - PA7
      
      // connection TFT DISPLAY ili9341 on SPI-2
      //
      // CS         - PB12
      // RESET /RST - PA8
      // DC / RS    - PA9
      // SCK        - PB13
      // MISO       - PB14
      // MOSI       - PB15
      

      RFM69HW - SPI 1 (without ili9341 TFT init tft.begin())

      24032 TSM:INIT
      24034 TSM:INIT:TSP OK
      24034 TSM:INIT:STATID=13
      24034 TSF:SID:OK,ID=13
      24034 TSM:FPAR
      24034 SGN:SGN:NREQ=255
      

      RFM69HW - SPI 1
      ILI9341 - SPI 2

      26029 TSM:FAIL:RE-INIT
      26029 TSM:INIT
      26030 !TSM:INIT:TSP FAIL
      26030 TSM:FAIL:CNT=2
      26030 TSM:FAIL:DIS
      26030 TSF:TDI:TSL
      

      Test code

      #define MY_DEBUG_VERBOSE_SIGNING
      #define MY_DEBUG
      #define MY_TRANSPORT_WAIT_READY_MS 3000
      
      #define MY_RADIO_RFM69
      #define MY_RFM69_FREQUENCY RFM69_868MHZ
      #define MY_IS_RFM69HW 
      #define MY_RFM69_NETWORKID 100  
      #define MY_NODE_ID 13
      #define RFM69_IRQ_PIN PA3  
      #define MY_RFM69_IRQ_NUM 3 
      #define MY_RFM69_SPI_CS PA4
      //#define MY_RFM69_TX_POWER_DBM 19
      #define MY_RFM69_NEW_DRIVER
      #define MY_RFM69_ENABLE_ENCRYPTION
      #define MY_SIGNING_SOFT
      #define MY_SIGNING_REQUEST_SIGNATURES
      
      #include <MySensors.h>
      
                                         
      #define CHILD_ID_RSSI_HIGH  7                // RSSI received signal level
      #define CHILD_ID_RSSI_LOW   8                // RSSI background noise level
      
      MyMessage msgRSSI1(CHILD_ID_RSSI_HIGH, V_LEVEL);
      MyMessage msgRSSI2(CHILD_ID_RSSI_LOW, V_LEVEL);
      uint8_t Send_rssi = 0;
      uint8_t Rec_rssi = 0; 
      
      void presentation() {  sendSketchInfo("Test node", "Ver. 1");present(CHILD_ID_RSSI_HIGH, S_SOUND); present(CHILD_ID_RSSI_LOW, S_SOUND); }
      
      ////////////////// TFT display ili9341 320x240 /////////////////////////////////////////////////////////////////////
      
      #include "SPI.h"
      #include "Adafruit_GFX_AS.h"
      #include "Adafruit_ILI9341_STM.h"
      //////////// SPI2
      
      #define TFT_DC PA9
      #define TFT_CS PB12
      #define TFT_RST PA8
      SPIClass  SPI_2(2);
      //#define SPI_PORT 2 //Use SPI2
      
      Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC, TFT_RST); // Use hardware SPI
       
      #define TFT_CIERNA 0x0000
      #define TFT_BIELA 0xFFFF
      #define TFT_ORANZOVA 0xFCA0
      
      unsigned long ResendMessageMillis;
      
      
      void setup() {
       Serial.begin(115200);
      //SPI.setModule(SPI_PORT);
      
      tft.begin(SPI_2);
      //tft.begin();
      tft.setRotation(1); tft.fillScreen(ILI9341_BLACK); 
      tft.setTextSize(1); 
      tft.setCursor(100, 70); 
      tft.setTextColor(TFT_ORANZOVA, ILI9341_BLACK);
      tft.print("test");
      
        
      ResendMessageMillis = millis();
      }
      
      void loop() {
      
            if ((millis() - ResendMessageMillis) > 10000) {
      
                 Send_rssi = RFM69_getSendingRSSI();   
                 wait(500);  
                 Rec_rssi = RFM69_getReceivingRSSI();  
                 wait(500);    
      
                 Serial.print("Send RSSI: ");
                 Serial.println(String((int)(Send_rssi)));
      
                 Serial.print("Receive RSSI: ");
                 Serial.println(String((int)(Rec_rssi)));
      
                 ResendMessageMillis = millis();
             }
      
      }
      
      posted in Hardware
      thom4s
      thom4s