Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PJONSoftwareBitBang between stm32f4 and arduino nano not working #416

Open
rozrabiak opened this issue May 20, 2022 · 3 comments
Open

PJONSoftwareBitBang between stm32f4 and arduino nano not working #416

rozrabiak opened this issue May 20, 2022 · 3 comments

Comments

@rozrabiak
Copy link

rozrabiak commented May 20, 2022

Communication between two arduino nanos working.
That same code in stm32f4 (stm32duino) not working, arduino nano says: Connection with device ID 10 is lost.
I'm using WeAct BlackPill pin PC14 (5V tolerant) and Arduino Nano PD5.

ARDUINO NANO CODE:

#include <PJONSoftwareBitBang.h> // Include only SoftwareBitBang
#define pjonPin 5 //pin komunikacyjny pjon

PJONSoftwareBitBang pjonBus(43);

void pjonReceiver(uint8_t *payload, uint16_t length, const PJON_Packet_Info &packet_info);
void error_handler(uint8_t code, uint16_t data, void *custom_pointer) {
if(code == PJON_CONNECTION_LOST) {
Serial.print("Connection with device ID ");
Serial.print(pjonBus.packets[data].content[0], DEC);
Serial.println(" is lost.");
}
if(code == PJON_PACKETS_BUFFER_FULL) {
Serial.print("Packet buffer is full, has now a length of ");
Serial.println(data, DEC);
Serial.println("Possible wrong bus configuration!");
Serial.println("higher PJON_MAX_PACKETS if necessary.");
}
if(code == PJON_CONTENT_TOO_LONG) {
Serial.print("Content is too long, length: ");
Serial.println(data);
}
};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pjonBus.set_error(error_handler);
pjonBus.strategy.set_pin(pjonPin);
pjonBus.set_receiver(pjonReceiver);
pjonBus.begin();
Serial.println("START");
}

void loop() {
pjonBus.update();
pjonBus.receive(1000);
pjonBus.send(10, "test", 4);
delay(1000);
}

void pjonReceiver(uint8_t *payload, uint16_t length, const PJON_Packet_Info &packet_info)
{
Serial.print("dane ze sterownika ");
Serial.println(packet_info.tx.id);
Serial.print("dane ");
Serial.println(payload[0]);
};

CODE FROM STM32DUINO:

PJONSoftwareBitBang pjonBus(10);
#define pjonPin PC14

void setup()
{
pjonBus.strategy.set_pin(pjonPin);
pjonBus.begin();
pjonBus.set_receiver(pjonReceiver);
pjonBus.set_error(pjon_error_handler);
}

void loop()
{
pjonBus.update();
pjonBus.receive(); //1000
}

void pjonReceiver(uint8_t *payload, uint16_t length, const PJON_Packet_Info &packet_info)
{
Serial.print("dane z pjon ");
Serial.println(payload[0]);
};

@gryzli133
Copy link

Did you try to use other pin on stm32? I had similar problems with ESP8266, but then I have used another pin and it starts to work.

@rozrabiak
Copy link
Author

rozrabiak commented Oct 10, 2022

Did you try to use other pin on stm32? I had similar problems with ESP8266, but then I have used another pin and it starts to work.

I'll try all pins :-)
F4 is on unsuporrted list with SBB...

My board: https://stm32-base.org/boards/STM32F411CEU6-WeAct-Black-Pill-V2.0.html

@2114L3
Copy link

2114L3 commented Sep 18, 2023

dont use delay in your main loop, you will be holding the nano out from running update() as it needs to for the non-blocking send command. keep the main loop running and use counters to trigger your send

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants