First of all, the bluepill circuit was tested with the "SimpleSender" and "SimpleReceiver" examples and it works.The bluepill can send and receive at least NEC and Samsung I.R. codes. The tests was done with a control remote and others Arduino UNO whith IRMP examples.
About my problem with bluepill and "ReceiveAndSend" example, my results over the Serial Monitor when I upload the sketch is:
START C:\Users\Juan\AppData\Local\Temp\arduino_modified_sketch_999079\ReceiveAndSend.ino from Sep 1 2020
Using library version 3.2.0
Ready to receive IR signals of protocols: SAMSUNG, SAMSG32, at pin PA4
Ready to send IR signals at pin PA5
I can lisen a first "pip" of 2000hz and a continuos tone (7500Hz more or less )over the buzzer and nothing hapens if I send a IR code with a remote.
My fisrt thoth thought was "there is a problem with Tone() / noTone() functions (timers)" and there is a mismatching between the pins just read in the console and the pins defined in the "PinDefinitionsAndMore.h" file .
I have wired like "PinDefinitionsAndMore.h" file says and it woks fine with others examples.
Then, now the builtin LED flashs when I use a IR remote (any remote Samsung or NEC) and runs "sendSamsungSmartHubMacro(false);" when the STM32 receives the 0xB54A (only the first time) , I lisen strange tones (like before) and the STM32 freezes.
My conclusions at this point is that the circuit is wired correctly but there is a problem with the software (timers).The circuit woks with easy examples ("SimpleSender" and "SimpleReceiver")but not with a litle more complex.
I chage the code of "ReceiveAndSend", and if I delete the use the Tone() functions and I simply send a code when I receive another then it works.
The code:
#include <Arduino.h>
/*
* Set library modifiers first to set input and output pin etc.
*/
#include "PinDefinitionsAndMore.h"
//#define IR_OUTPUT_IS_ACTIVE_LOW
#define IRMP_PROTOCOL_NAMES 1 // Enable protocol number mapping to protocol strings - requires some FLASH.
#define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1
#define IRSND_SUPPORT_SAMSUNG_PROTOCOL 1
/*
* After setting the definitions we can include the code and compile it.
*/
#define USE_ONE_TIMER_FOR_IRMP_AND_IRSND // otherwise we get an error: redefinition of 'void __vector_8()
#include <irmp.c.h>
#include <irsnd.c.h>
IRMP_DATA irmp_data;
IRMP_DATA irsnd_data;
void sendSamsungSmartHubMacro(bool aDoSelect);
void IRSendWithDelay(uint16_t aCommand, uint16_t aDelayMillis);
void setup()
{
#if defined(MCUSR)
MCUSR = 0; // To reset old boot flags for next boot
#endif
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
delay(2000); // I need time to open the Serial monitor
#if defined(__AVR_ATmega32U4__)
while (!Serial); //delay for Leonardo, but this loops forever for Maple Serial
#endif
#if defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#endif
#if defined(__ESP8266__)
Serial.println(); // to separate it from the internal boot output
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRMP));
/*
// This makes that we can't receive nothing and lisen a 7.5 Khz tone
tone(TONE_PIN, 2200);
digitalWrite(LED_BUILTIN, HIGH);
delay(400);
digitalWrite(LED_BUILTIN, LOW);
noTone(TONE_PIN);
*/
irmp_init();
irmp_irsnd_LEDFeedback(true); // Enable receive signal feedback at LED_BUILTIN for receive and send
irsnd_init();
#if defined(ARDUINO_ARCH_STM32)
Serial.print(F("Ready to receive IR signals of protocols: "));
irmp_print_active_protocols(&Serial);
Serial.println(F("at pin PA4")); // the internal pin numbers are crazy for the STM32 Boards library
Serial.println(F("Ready to send IR signals at pin PA5"));// the internal pin numbers are crazy for the STM32 Boards library
#else
Serial.print(F("Ready to receive IR signals of protocols: "));
irmp_print_active_protocols(&Serial);
Serial.println(F("at pin " STR(IRMP_INPUT_PIN)));
Serial.println(F("Ready to send IR signals at pin " STR(IRSND_OUTPUT_PIN)));
#endif
irsnd_data.protocol = IRMP_SAMSUNG32_PROTOCOL;
irsnd_data.address = 0x0707;
irsnd_data.flags = 1; // repeat frame 1 time
}
void loop()
{
if (irmp_get_data(&irmp_data))
{
irmp_result_print(&irmp_data);
switch (irmp_data.command)
{
case 0xB54A: // The pause key on the bottom of my Samsung remote
Serial.println(F("Pause key detected, open SmartHub"));
IRSendWithDelay(0x9768, 1); // To send anything
break;
default:
break;
}
// Flush repeats received
irmp_get_data(&irmp_data);
}
}
void IRSendWithDelay(uint16_t aCommand, uint16_t aDelayMillis)
{
irsnd_data.command = aCommand;
irsnd_send_data(&irsnd_data, true); // true = wait for frame to end. This stores timer state and restores it after sending
delay(aDelayMillis);
}
Other usefull data:
I use the defaults pins that the file "PinDefinitionsAndMore.h" indicate:
define IRMP_INPUT_PIN PA6
define IRSND_OUTPUT_PIN PA7
define TONE_PIN PA3
I use Windows 10
I use Arduino IDE 1.8.13(Windows Store 1.8.42.0)
I use the library IRMP 3.2.0, installed from Library Manager from the Arduino IDE
I have configured the board "Generic STM32F1 series" -> "BluePill F103C8" installed from the Board Manager with the name "STM32 Cores" by STMicroelectronics 1.9.0
If you has read all of this... :) thanks for you patience, I hope I have explained the problem well.
Bug Report
Arduino Platform
IDE
IR-Protocol
Example to reproduce the issue
Pin(s) used for IR-receive, if not default
Default
Version
Current behavior
First of all, the bluepill circuit was tested with the "SimpleSender" and "SimpleReceiver" examples and it works.The bluepill can send and receive at least NEC and Samsung I.R. codes. The tests was done with a control remote and others Arduino UNO whith IRMP examples.
About my problem with bluepill and "ReceiveAndSend" example, my results over the Serial Monitor when I upload the sketch is:
I can lisen a first "pip" of 2000hz and a continuos tone (7500Hz more or less )over the buzzer and nothing hapens if I send a IR code with a remote. My fisrt thoth thought was "there is a problem with Tone() / noTone() functions (timers)" and there is a mismatching between the pins just read in the console and the pins defined in the "PinDefinitionsAndMore.h" file . I have wired like "PinDefinitionsAndMore.h" file says and it woks fine with others examples.
If I comment:
Then, now the builtin LED flashs when I use a IR remote (any remote Samsung or NEC) and runs "sendSamsungSmartHubMacro(false);" when the STM32 receives the 0xB54A (only the first time) , I lisen strange tones (like before) and the STM32 freezes.
My conclusions at this point is that the circuit is wired correctly but there is a problem with the software (timers).The circuit woks with easy examples ("SimpleSender" and "SimpleReceiver")but not with a litle more complex.
I chage the code of "ReceiveAndSend", and if I delete the use the Tone() functions and I simply send a code when I receive another then it works. The code:
Other usefull data:
I use the defaults pins that the file "PinDefinitionsAndMore.h" indicate:
define IRMP_INPUT_PIN PA6
define IRSND_OUTPUT_PIN PA7
define TONE_PIN PA3
I use Windows 10
I use Arduino IDE 1.8.13(Windows Store 1.8.42.0)
I use the library IRMP 3.2.0, installed from Library Manager from the Arduino IDE I have configured the board "Generic STM32F1 series" -> "BluePill F103C8" installed from the Board Manager with the name "STM32 Cores" by STMicroelectronics 1.9.0
If you has read all of this... :) thanks for you patience, I hope I have explained the problem well.