I found this nice initiative https://github.com/petoknm/STM32_NEC_Decode
but that’s only focussing on the Decode piece and not the sending part.
As IRlib has done a great job in decoupling the HW related timer things from the decoding and sending logic I thought it might be a nice project to sink my teeth in.
maybe it’s fairly easy to just focussing on the hardware specific parts in the library.
Although I’m not as seasoned as most of you guys out here on the board,
An I think it might be overly ambitious for me, but still may be worth a try.
Best regards,
Paul
Victor_pv was looking into it here and GarthC stated he was using NEC here.http://www.stm32duino.com/viewtopic.php … t=20#p3896
But, I have an opinion on this (I would, would not I?) A tremendous amount of bandwidth is given up to a software IR solution, IMO. The STM32F1 has the clock cycles, but many years ago, I developed an independent uC approach based on a tiny85. I was doing some real time instrument displays for a friend that owns an Experimental plane and I simply did NOT want to interfere with my loop repetition rate by throwing in IR … this was on an AVR 2560. I wanted IR to be used to set-up the realtime clock and to enter offsets, corrections factors, etc. In today’s world, I would use Bluetooth.
Anyway,here is the dedicated t85 solution.
Ray
“Waste not your extra processor cycles today, you may need them tomorrow!”
One thing to bear in mind is that the example code uses STM’s HAL API, but our core does not use the HAL. ( our core was originally written my Leaflabs long before they released the HAL API)
So you would need to replace the HAL calls with code to directly access the hardware ( but as the HAL is now open source, it would be reasonably easy to see what the HAL calls do, or possibky just copy them imto your code.)
I noticed that STM have several application notes on IR decoding and encoding, but I dont know if any apply to the F103 ( one AN is for the F0 and F3 but I dont know why they focussed on those to devices and not the F1 and F2 as well)
Anyway, if you choose to have a go at making a STM32 IR lib, I am sure it would be handy for a lot of people
I’ve found several timer docs and presentations that all the timing stuff could be handled by the hardware directly
as the STM32FXXX’es all have hardware timers.
That’s when I figured it shouldn’t be too hard as long as I could stick to ST’s good advice,
examples etc. and possibly copy in several code sniplets as long as it was compatible with the duino Core.
and that’s probably where it gets hairy..
some more background on my motivation:
I’ve set myself on a target to develop a laser tag game (With overly ambitious targets)
Various game types (capture the flag) (hunt the rabbit) team A vs Team B etc. and more of such things.
So a player needs to know by whom of which team he/she was hit.
Typically I need line of sight IR communication as part of the
Ideally I’d like a central server to keep track of the scores and that kind of palaver.
similar to the comercial stuff in lasergame venues.
However that’s the long term goal… short term I’d like to work on the individual components.
and IR send recieve is the most important part.
I’ve tried stuff with the pro-mini (as the HW needs to be tiny enough to be built in a gun.)
but coupling an SPI OLED display AND ESP8266 AND buttons AND LEDs AND a Laser AND IRsensor AND an MP3 module for the sounds
Even if I’d do I2C stuff instead of SPI etc. I’d probably still end up in an assylum before it works.
All the individual stuff worked great, some together also, but all together as a final product…not so
I even looked at shift out registers etc. but that didn’t help much due to fixed pin functions and overlap of some functions
and last but not least the mini had not enough oomph.
So I moved over to the nodeMCU and things quickly got worse when I realised that that thing was unstable as hell and didn’t solve much of my initial problems. hahaha.. stupid me for not digging through the specs. enough before I bought a set. buy hey they were cheap ![]()
So I learned from that mistake and started by sifting MCU’s designs.
The hardware of the STM32 looked pretty good and fit for purpose
The pin flexibility interrupts timer functions etc. all looked promissing.
only one caveat… a missing IR library.. well at least in duino-land
Now That’s the why, behind my story.
Ray’s comment on not willing to spend SW time cycles is an interresting view
I came across that on the pro mini as well (realtime handling of all the functions became a horror quickly as you can imagine)
Paul
Re:Using STs examples
The STM32s have some cool hardware features, (most of which we have only scratched the surface of)
So if ST have some application notes on how to use the hardware more efficiently for this, its definitely worth reading.
However, be aware that different processors in the family have additional hardware that the F103 does not possess.
e.g. I think the F3 series seems to be targeted at analog input and processing.
Both are terrific open source (vast) drivers and MCU management that I use, and watch somewhat sadly, while ArduinoARM people reinvent these wheels. Freescale/NXP has something similar to HAL and SPL but I find them to be way inferior and limited.
Both are terrific open source (vast) drivers and MCU management that I use, and watch somewhat sadly, while ArduinoARM people reinvent these wheels. Freescale/NXP has something similar to HAL and SPL but I find them to be way inferior and limited.
Prior to that, although you could download the SPL and use it for your own commercial or non-commercial products, it was not possible to write an Open Source product which referenced the SPL, without requiring the end user to download the SPL separately (as the code contains a non-redistribution clause)
Hence why, we believe, that Leaflabs had to code their own API to the hardware from scratch.
Its really only since the beginning of the year that the output from the STM Cube could be used for Open Source projects, and even then some files initially had licensing issues (though not deliberately)
Note. I know that some other projects, like MakerLabMe etc have published SPL code from STM in their repo’s, but AFIK know it most likely breaches the terms of use in those SPL files to redistribute them (e.g on GitHub)
SPL and HAL – I’ve been working with them for only 1 1/2 years. I’m not an IP guru, but they are provided by ST to anyone who wants to register with name/email and download. No fees I’m aware of to incorporate these into products. Indeed, the ST’s purpose of these is to speed time to market and cost of development. NXP/Freescale does the same thing.
I’m doing commercial work with with HAL and there’s no issue with leaving their credits in the source, nor if we have to, crediting them in the release of the product that uses the binaries. Like many product cycles, no ST-original source code is provided, nor usually wanted by the customers.
I do NOT modify ST’s code for obvious reasons – mainly that I don’t need to and also I don’t want to cause a configuration mess as they release updates several times a year. I can take my sources minus ST’s sources from HAL and CubeMX, and create a baseline and tell someone how to do their own download of ST’s code and code-generate with CubeMX and get the same result. If need be.
non-commercial applications – I’ve not read the fine print. But I don’t think there are restrictions other than leaving the ST credit in place. Seems fair to me, as if I had to develop all those drivers from bare metal, it would have made the cost and schedule, and complexity, impractical. Not like a bit of code for a PIC or AVR.
Hobby market… well, you know that story. The best is to get it into University labs for imprinting – as Apple is want to do.
Lastly, the low cost of MCUs, and M3/M4 with generous sized flash/RAM – makes it illogical to do as we all used to do way back.. work for hours with an undersized MCU is false economics. Big non-recurring labor costs make sense only if you are building a million and have a big amortization base. For avocational.. we’re talking insignificant parts cost deltas.
So, I certainly missed the point of the posting.
It means that its fine for you and anyone else to download and use the code
However, it was not possible to base an Arduino “core” on the STM, as the Arduino Core’s are shipped as source code, and it was not possible to include any SPL code.
If you do work for anyone and use the SPL, Technically you couldn’t (prior to this year) bundle the SPL with your code when you hand it over
Your client, technically had to download their own copy of the SPL to compile your code
Of course this is all history now, as STM changed their IP license this year to allow redistribution.
I was just trying to explain why the LibMaple Arduino core written by Leaflabs in 2012 did not use the SPL.
<…>
So, I certainly missed the point of the posting.
Have you guys noticed that this forum is not being recommended by Leaflabs? Cool.
You can still read the docs. The forums will remain active until August 2016, but at that point they will be converted to a static archive. Consider checking out the resources and community at http://www.stm32duino.com instead.
Ray
Have you guys noticed that this forum is not being recommended by Leaflabs? Cool.
You can still read the docs. The forums will remain active until August 2016, but at that point they will be converted to a static archive. Consider checking out the resources and community at http://www.stm32duino.com instead.
Ray
It has a lot of things already implemented. I think the “only work” needed to be done is to replace the interrupt an configuration calls that are made directly to AVR HW for ones to STM32 HW…
I’ve downloaded and I’m getting these errors:
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp: In member function 'void IRrecv::enableIRIn()':
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:115:6: error: 'cli' was not declared in this scope
cli();
^
In file included from G:\User\Documents\Arduino\libraries\IRremote\IRremote.h:24:0,
from G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:1:
G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:246:3: error: 'TCCR2A' was not declared in this scope
TCCR2A = _BV(WGM21); \
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:120:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
TIMER_CONFIG_NORMAL();
^
In file included from G:\User\Downloads\arduino-1.6.5-r5\hardware\Arduino_STM32\STM32F1\cores\maple/Arduino.h:30:0,
from G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:24,
from G:\User\Documents\Arduino\libraries\IRremote\IRremote.h:24,
from G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:1:
G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:246:16: error: 'WGM21' was not declared in this scope
TCCR2A = _BV(WGM21); \
^
G:\User\Downloads\arduino-1.6.5-r5\hardware\Arduino_STM32\STM32F1\cores\maple/wirish.h:103:25: note: in definition of macro '_BV'
#define _BV(bit) (1 << (bit))
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:120:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
TIMER_CONFIG_NORMAL();
^
In file included from G:\User\Documents\Arduino\libraries\IRremote\IRremote.h:24:0,
from G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:1:
G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:247:3: error: 'TCCR2B' was not declared in this scope
TCCR2B = _BV(CS21); \
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:120:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
TIMER_CONFIG_NORMAL();
^
In file included from G:\User\Downloads\arduino-1.6.5-r5\hardware\Arduino_STM32\STM32F1\cores\maple/Arduino.h:30:0,
from G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:24,
from G:\User\Documents\Arduino\libraries\IRremote\IRremote.h:24,
from G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:1:
G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:247:16: error: 'CS21' was not declared in this scope
TCCR2B = _BV(CS21); \
^
G:\User\Downloads\arduino-1.6.5-r5\hardware\Arduino_STM32\STM32F1\cores\maple/wirish.h:103:25: note: in definition of macro '_BV'
#define _BV(bit) (1 << (bit))
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:120:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
TIMER_CONFIG_NORMAL();
^
In file included from G:\User\Documents\Arduino\libraries\IRremote\IRremote.h:24:0,
from G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:1:
G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:248:3: error: 'OCR2A' was not declared in this scope
OCR2A = TIMER_COUNT_TOP / 8; \
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:120:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
TIMER_CONFIG_NORMAL();
^
G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:249:3: error: 'TCNT2' was not declared in this scope
TCNT2 = 0; \
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:120:2: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
TIMER_CONFIG_NORMAL();
^
G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:222:30: error: 'TIMSK2' was not declared in this scope
#define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A))
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:123:2: note: in expansion of macro 'TIMER_ENABLE_INTR'
TIMER_ENABLE_INTR;
^
In file included from G:\User\Downloads\arduino-1.6.5-r5\hardware\Arduino_STM32\STM32F1\cores\maple/Arduino.h:30:0,
from G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:24,
from G:\User\Documents\Arduino\libraries\IRremote\IRremote.h:24,
from G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:1:
G:\User\Documents\Arduino\libraries\IRremote\IRremoteInt.h:222:43: error: 'OCIE2A' was not declared in this scope
#define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A))
^
G:\User\Downloads\arduino-1.6.5-r5\hardware\Arduino_STM32\STM32F1\cores\maple/wirish.h:103:25: note: in definition of macro '_BV'
#define _BV(bit) (1 << (bit))
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:123:2: note: in expansion of macro 'TIMER_ENABLE_INTR'
TIMER_ENABLE_INTR;
^
G:\User\Documents\Arduino\libraries\IRremote\irRecv.cpp:127:6: error: 'sei' was not declared in this scope
sei(); // enable interrupts
^
Circuit Cellar magazine. May 2016.
If you have the STM32 variety that can do AND gate operations on 2 output clocks then it’s much easier..
set the 38Khz signal as a base freq. and then turn the signal on and off on the 2nd timer to get the right output.
I could do it that way by combining two timers on separate pins but that would consume two pins and needs two extra transistors on the outside for F103.type boards which is probably what the majority of hobby bobs are using.
but that’s a HW hack to get things right.
another way would be to build a mini timer circuit for the base freq. (e.g. 38Khz) using a 555 timer IC and a few resistors but again that’s a HW hack I’d like to avoid if possible as it is a bit besides the point of a SW library.
but then again it would simplify the problem considerably
The reason I looked at IR lib is because the signal generation (protocol specific) and hardware part are split in the library itself.
and all is housed in separate functions which is great.
This makes IRlib pretty portable but the HW part proved more difficult to me than initally expected (due to the points mentioned above).
In the current library there is a lot of low level AVR stuff going on to get the timings right
(stop interrupts, register pusing and shoving enabling interrupts again etc.)
In the STM’s this could be done similar but that might have a huge impact on the interrups and thus possibly on other libraries/functions in a project.
so I’m not too fond of that method and am looking for alternatives.
It looks like I’ll not be having something working soon BTW.
Also becaue I’m struggling in how to combine HAL stuff with the duino IDE I’m not sure how much I end up in conflict with the core libs by doing so.
And especially as I’m not a seasoned programmer things take extra time ![]()
but still it’s good time spent !
Paul
IRMP on STM32 – a USB IR receiver / transmitter / off switch with wakeup timer
https://www.mikrocontroller.net/article … keup-Timer
Here with Google translate
https://translate.google.it/translate?s … edit-text=
IRMP on STM32 – a USB IR receiver / transmitter / off switch with wakeup timer
https://www.mikrocontroller.net/article … keup-Timer
Found an original english page here
https://www.mikrocontroller.net/articles/IRMP_-_english
IRMP on STM32 – a USB IR receiver / transmitter / off switch with wakeup timer
https://www.mikrocontroller.net/article … keup-Timer
zoomx wrote:I found this german post
IRMP on STM32 – a USB IR receiver / transmitter / off switch with wakeup timer
https://www.mikrocontroller.net/article … keup-Timer
Here with Google translate
https://translate.google.it/translate?s … edit-text=
For what its worth, here is ST’s take on the problem -> http://www.st.com/content/ccc/resource/ … 053084.pdf
It would be good to get a software only solution of course, either based on ST”s approach or perhaps using DMA to shift out a 1010101 bit stream at 36 38 or 40kHz in to which we inject our data. Getting the timing right is of course the big trick with IR, but from personal experience (my day job involves software development for set TV top boxes for Hotels), once you have your that nailed, the rest is relatively trivial.
I was using the ST application note linked by Andy in the previous post. That AN is for F0 and F3 chips that include an internal circuit to connect 2 timer outputs, in a way that they will provide an output with the 56Khz, 48Khz, or whatever needed for the IR receiver used in the application.
The F1 lacks that internal circuit, but nothing prevents you from using 2 timer outputs and implementing the circuit on the PCB with a couple of transistors and little more. That was my approach.
I had the code half way translated from the STM std peripheral library to mostly libmaple, but like I said that was last year and I had to put it aside for a long time, so I don’t remember how close I was to getting it to work. I remember I had to order IR leds and put it aside and started working on a wav player using a timer to generate a PCM output. I got that working, and I didn’t feel the IR stuff was much more complex, but then didn’t have time to back to it.
It can definitely use DMA, and I planned to turn to DMA as soon as I had it working, to reduce the CPU load.
I do not think it’s complicated. Anyone with a bit of experience in C and the STM32F1 timers should be able to complete it faster than me.
I was using the ST application note linked by Andy in the previous post. That AN is for F0 and F3 chips that include an internal circuit to connect 2 timer outputs, in a way that they will provide an output with the 56Khz, 48Khz, or whatever needed for the IR receiver used in the application.
The F1 lacks that internal circuit, but nothing prevents you from using 2 timer outputs and implementing the circuit on the PCB with a couple of transistors and little more. That was my approach.
I had the code half way translated from the STM std peripheral library to mostly libmaple, but like I said that was last year and I had to put it aside for a long time, so I don’t remember how close I was to getting it to work. I remember I had to order IR leds and put it aside and started working on a wav player using a timer to generate a PCM output. I got that working, and I didn’t feel the IR stuff was much more complex, but then didn’t have time to back to it.
It can definitely use DMA, and I planned to turn to DMA as soon as I had it working, to reduce the CPU load.
I do not think it’s complicated. Anyone with a bit of experience in C and the STM32F1 timers should be able to complete it faster than me.
Interesting note. Would one want a generic library, or something that can emit RC5 directly ?
I made an adaptation for irmp reception for stm32duino.
at https://github.com/karawin/irmp-master
Tested with the blue card.
I made an adaptation for irmp reception for stm32duino.
at https://github.com/karawin/irmp-master
Tested with the blue card.
Have to test it ASAP!
Ok, let me know.
can not compile
In file included from C:\Documents and Settings\Vadim\Мои документы\Arduino\hardware\Arduino_STM32\STM32F1\libraries\irmp-master-master/irmp.h:18:0,
from C:\HELP\07ELECTRONIK\09MK\20MY\40shpagi\05LCD touch\00progr\24ver\PVS\PVS.ino:165:
C:\Documents and Settings\Vadim\Мои документы\Arduino\hardware\Arduino_STM32\STM32F1\libraries\irmp-master-master/irmpsystem.h:98:22: fatal error: avr/io.h: No such file or directory
# include <avr/io.h>
^
compilation terminated.
exit status 1
Ошибка компиляции для платы Maple Mini.
You are in
#if defined(ATMEL_AVR)
case.
I made the modification for
#elif defined(BOARD_generic_stm32f103c)
Please change all BOARD_generic_stm32f103c to your mapple mini definition or better, add an ifdef or elif case.
Probably
if defined(ARDUINO_MAPLE_MINI)
They are at
Search “stm32duino” (3 hits in 3 files)
C:\Users\jp\Documents\Arduino\libraries\irmp-master\irmpconfig.h (1 hit)
Line 162: * Change hardware pin here for STM32Duino
C:\Users\jp\Documents\Arduino\libraries\irmp-master\irmpsystem.h (1 hit)
Line 44: #elif defined(BOARD_generic_stm32f103c) // STM32DUINO
C:\Users\jp\Documents\Arduino\libraries\irmp-master\irsndconfig.h (1 hit)
Line 170: * generic_stm32f103c(STM32duino, see IRSEND.ino)
Thanks, it compile now. I change all to ARDUINO_MAPLE_MINI
Ok found irmpconfig.h and change IN PIN to PA8
* Change hardware pin here for STM32Duino
*---------------------------------------------------------------------------------------------------------------------------------------------------
*/
#elif defined(ARDUINO_MAPLE_MINI)
# define IRMP_BIT_NUMBER PA8 // use C15 pin
and it WORK!!!
everyone laughs are all happy
Thanks for library =)
Great. Enjoy.
\Arduino\libraries\TimerOne/TimerOne.h:301:17: error: conflicting declaration 'TimerOne Timer1'
extern TimerOne Timer1;



