Good evening,
I just migrated to Mbed Studio from Mbed Online, I have a part of my code that uses “__NOP();” but the compiler crashes because it does not recognize the function! How to find this function or what to replace it with?
Here is the code:
void WS2812::WriteDataOut(int dataLed[])
{
const int nBit8 = 8,
nBytePerLed = 3,
nBit = nLed * (nBytePerLed * nBit8);
int data[nBit+1];
int buff[nBit8];
for(int x = 0; x < nLed; x ++)
{
int_to_binary(dataLed[x * nBytePerLed], buff, nBit8);
for(int bit = 0; bit < 8; bit ++){data[bit + (x * (nBit8 * nBytePerLed))] = buff[bit];}
int_to_binary(dataLed[(x * nBytePerLed)+1], buff, nBit8);
for(int bit = 0; bit < 8; bit ++){data[bit + (x * (nBit8 * nBytePerLed)) + nBit8] = buff[bit];}
int_to_binary(dataLed[(x * nBytePerLed)+2], buff, nBit8);
for(int bit = 0; bit < 8; bit ++){data[bit + (x * (nBit8 * nBytePerLed)) + (2 * nBit8)] = buff[bit];}
}
__disable_irq();
for (int i = 0; i < (nLed * (nBytePerLed * nBit8)); i++)
{
int j = 0;
if (data[i])
{
Data = 1;
for (; j < 5; j++) {__nop();}
Data = 0;
for (; j < 0; j++) {__nop();}
}
else
{
Data = 1;
for (; j < 0; j++) {__nop();}
Data = 0;
for (; j < 5; j++) {__nop();}
}
}
__enable_irq();
}
Thanks in advance for your help,
Sincerely Antoine
Serial API was splited to BufferedSerial (no interrupts) and UnbufferedSerial (interrupts are possible), but these APIs do not contain printf, getc, putc functions and so on. There are only read and write methods.
So you have two options. you can change all objects of Serial to one of variants above (we use UnbufferedSerial for now) and all getc/putc to read/write.
Change from
Serial pc(...);
// getc
int c = serial.getc();
// putc
serial.putc(c);
Thank you very much for your answer, I have tested with UnbufferedSerial but I get this message:
[Error] mbed-midi_Adapter.hpp@29,24: no member named 'getc' in 'mbed::UnbufferedSerial'
[Error] mbed-midi_Adapter.hpp@34,17: no member named 'putc' in 'mbed::UnbufferedSerial'
[ERROR] In file included from .\MIDI\mbed-midi_Adapter\mbed-midi_Adapter.cpp:1:
I then tested with BufferedSerial but I get this:
[Error] mbed-midi_Adapter.hpp@29,24: no member named 'getc' in 'mbed::UnbufferedSerial'
[Error] mbed-midi_Adapter.hpp@34,17: no member named 'putc' in 'mbed::UnbufferedSerial'
[ERROR] In file included from .\MIDI\mbed-midi_Adapter\mbed-midi_Adapter.cpp:1:
Sorry my answer was not much clear probably. I did edit my previous post.
If it will be still not clear, then share a link of library what you use and I will try to explain better in practice.
Thank you very much for your analysis and example.
For the moment I solved the problem by compiling under MBED OS-5.15.7 which still uses “Serial”.
But I will test your solution in order to migrate to Mbed OS 6
I come back to you concerning the compilation, I found that I must add the file “mbed_app.json” as in the example “mbed-os-example-blinky-baremetal-5” in order not to use RTOS and thus not to exceed the RAM and or Flash memory.
Here is the file:
For the needs of my project I use a Bootloader on the USB port of the KL25Z and I must therefore shift the flash memory start of the program so that it starts.