periph | Go·Hardware·Lean
kandi X-RAY | periph Summary
kandi X-RAY | periph Summary
Documentation is at
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of periph
periph Key Features
periph Examples and Code Snippets
Community Discussions
Trending Discussions on periph
QUESTION
Hi I am using STM32F407ZET6 Microcontroller and I want to use multiple streams of DMA1. Is it possible to trigger two different streams of the same DMA for transferring data to two different peripherals simulatenously. (Like in Parallel).
In the advanced AHB bus matrix I observe that for each DMA there are only two lines, one for memory and one for peripheral, which suggest to me that at any time at max two streams can perhaps run in parallel and that also if none of the streams are really doing memory<->peripheral transfer. Is this assumption correct? And, is this also correct that to run two streams in parallel through a single DMA they should not be doing memory<->peripheral transfer? what I mean is that by the look of AHB matrix it felt if only Mem to Mem and Periph to Periph transfers are done then probably two streams can run in parallel, but if any one of them does memory<->peripheral transfer then the use of DMA memory and peripheral interface for a single transfer will probably make that NOT possible. Can you shed some light on this?
I would like to request some guidance on this particular topic as i could not find satisfactory information on it... And if it is dependent on the bus bandwidth to transfer streams in parallel then how the bandwidth is divided among multiple channels for a single bus to perform multiple transfer.... Some If there is any such example, i would be thankful. As a reference I have put the AHB matrix below:
...ANSWER
Answered 2021-Jun-01 at 11:41You can only select one channel per stream, but you can enable all 8 streams per DMA peripheral at once if you like, subject to the hardware defect listed in the errata sheet*.
Each of the masters take turns to access the buses. Once a master takes the bus it decides how long to use it for. For the DMA master, this is configured with the MBURST and PBURST bits of the DMA_SxCR register. If you require very low latency in the system and do not want the processor or another master (ethernet etc) to be stalled and have to wait for the DMA to get off the bus then set the burst configuration short (but even the longest burst you can configure will still only be a microsecond or so).
(*) there is a hardware defect in DMA2 which disallows concurrent use of AHB and APB peripherals, see the errata for details.
QUESTION
TLDR: I am getting consistent freezes when printing floats to a String via arduinos String
class. Previously I was getting the same freeze with sprintf and %f. I've solved the problem using the PString class, but I would like to understand the issue.
FULL STORY: I have a rather large c++ codebase for arduino SAMD architecture (a MKRZero), that started freezing recently on a line of code I hadn't touched in a long time. This was a call to sprintf
with %f
, which was oddly working as expected previously. After some research on SO and google, I realized that float formatting via sprintf isn't supported on Arduino, and after ruling out dtostr (due to not being on AVR), I tried with Arduinos String
class. This temporarily solved the problem, but the freeze resurfaced after testing the system with some different external periphicals (I2C slaves that can be connected and disconnected). So the exact same code, but some differences in the parts of it being exersized due to the different periphical.
The codebase is quite large (several 1000s lines), and I haven't been able to reproduce with a simple example. So unfortunately without much context, these are the lines that fail:
...ANSWER
Answered 2021-Apr-16 at 13:12After a lot of debugging, it seems that the issue indeed does have to do with ability of Arduino to print floats to string, and not with pointers or non-terminated string issues in my code.
It seems to be stalling in the dtostrf()
call of the String constructor:
QUESTION
I've set up two STM32 Boards, one as SPI-master, the other one as slave. I write directly to registers without any framework. Master to slave communication is working perfectly. But the slave sends garbage sometimes.
I first tried interrupts, but the slave would always send garbage and often receive garbage. Now I implemented DMA. This is working way better, the slave now always receives correct data. But sending is still an issue.
If the transmission is 3 to 5 Bytes long the data from the slave is correct in 95% of all cases. If the transmission is longer then 5 bytes, then after the 4th or 5th byte there is just random byte foo. But the first 4 bytes are nearly (95%) always correct.
The signals are clean, I checked them with an oscilloscope. The data which the master receives shows up properly on MISO. So I guess the slave somehow writes garbage into the SPI DR, or the data register gets messed up. I know SPI slaves on non-FPGAs are tricky, but this really is unexpected...
Anyone can point me a direction? I'm desperate and thankful for any bit of advice.
This is the code
...ANSWER
Answered 2021-Mar-26 at 09:46So, I did it. It was a whole bunch of things. Also, my assumption in the question was wrong. My slave did not receive/send valid data.
The signals were shown as clean by the oscilloscope, but the scope itself was adding noise to the lines, that was not visible on the scope itself. Not measuring the lines helped.
I put 100 OHM resistors close to the MASTER pins. This was not working, out of desperation I put the resistors close to the slave instead. Suddenly I got valid data. (This has been the main culprit all along)
According to the comment of Ashley Miller, I implemented a circular buffer, where I always send a fixed length every time. So the slave knows exactly what to expect. This mitigated eventual errors that could be produced when switching off / resetting the DMA shortly after the transmission.
The UART tricked me also. When getting too much data at once ( as little as 20 or 30 bytes! ) my terminal program gliched and threw the bytes randomly around. So part of the problem was just that... I'm using GtkTerm for those who are interested.
The Clock mode CPOL= 0 and CPH = 0 doesn't work at all. I set both master and slave to the same setting and it just received garbage. If I loop back the master to itself (connect MISO to MOSI a.k.a. exclude the slave) then it works regardless of clock mode. This seems to stem from a timing issue, where the slave has to react too fast and can't handle even the slowest possible speed (approx. 100 kHz). I did not go into details on this.
I hope I could help someone with this.
QUESTION
I am trying to send realtime data from a sensor through flask to the front-end through jquery. Right now my script uses setInterval(..., 1000);
to update the data through a ajax request.
However, I would like to update the jquery request when new sensordata is received from flask, as the framerate from the sensor differ and its hard to set a specific interval to make it realtime.
Is it possible to use some kind of signal in the jquery code when new data is sent through @app.route('/data')
?
Python script:
...ANSWER
Answered 2020-Dec-15 at 11:27For realtime data, use 'text/event-stream' MIME type
return Response(generate_random_data(), mimetype='text/event-stream')
or yield a server-side event (i used this type with the below snippet)
Here is part of a front-end snippet i used:
QUESTION
I've been working on an embedded C project for a few days and I've found some interesting configuration files that use a lot of macros.
The code looks like this
...ANSWER
Answered 2020-Nov-10 at 16:09The code in “config.h” appears designed for some earlier code to define CONFIG_PERIPH_0
or CONFIG_PERIPH_1
but not both.
If CONFIG_PERIPH_0
is defined, this code defines CONFIG_PERIPH_1
to be null—any use of CONFIG_PERIPH_1(…)
is replaced with nothing (an empty token list). Conversely, if CONFIG_PERIPH_1
is defined, this code defines CONFIG_PERIPH_0
to be null.
Then the code uses both CONFIG_PERIPH_0
and CONFIG_PERIPH_1
, knowing that the one that was defined by the earlier code will be replaced as defined and the other will have no effect.
Whether a macro is defined as object-like (#define foo replacement-tokens
) or function-like (#define foo(argument) replacement-tokens
) is irrelevant to the defined
operator or the #ifdef
directive. If the macro is defined either way, the defined
operator evaluates as true. If it is not defined, the operator evaluates as false.
QUESTION
I have been doing some modifications on an .xml file using python and lxml library and ElementTree. I have this result:
...ANSWER
Answered 2020-Oct-27 at 22:05from lxml import etree
root = etree.parse(r'')
for name in root.xpath('//name[./following-sibling::displayName]'):
name.getnext().text = name.text
print( etree.tostring(root, pretty_print=True).decode('utf-8') )
QUESTION
I am trying to convert UART loopback program to corresponding hex code. The command
...ANSWER
Answered 2020-Sep-06 at 18:35You have this error because rt/rt_api.h is not present in your riscv gcc search path.
To see the folders present in search path you can add -v
option to your command or use:
QUESTION
I have a gpio class which is templated:
...ANSWER
Answered 2020-May-18 at 15:24This
QUESTION
I am using the ST32 I-cube example code and trying to initiate the ADC with the following code:
...ANSWER
Answered 2020-Feb-17 at 18:43I'm almost certain that ADC
is not a valid instance, you should be using ADC1
(or 2 or whatever) instead.
Looking in one of the STM32 header files shows:
QUESTION
I'm trying to set communication between esp32 (master) and stm32 (slave) over SPI. esp32 is running under micropython and sends four bytes, for example
spi.write_readinto(b'\x31\x32\x33\x34', buf)
stm32' code is here (instead of this i use SPI_InitDef.SPI_NSS = SPI_NSS_Soft;
)
ANSWER
Answered 2019-Nov-05 at 09:17I think the following code is not correct (but I don't know what the function SPI_I2S_ReceiveData
is doing):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install periph
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page