My mypy resides in memory from where it is executed (no drive).
I need to setup a DMA controller and for that I need to map an area of my entire memory (essentially outside the heap defined area) and write the start address to this DMA controller.
How do I achieve this in mypy. Do I need to write my own c module or is there an buildtin feature which can give me this address. I'm guessing that I need two address one for accessing the area inside mypy and one for the DMA controller.
I am thinking though I have not tested this but creating a buffer in the mypy virtual environment will only give me an relative point inside the heap mapped area of the total ram area.
Regards
How to find the absolute memory pointer to a buffer.
Re: How to find the absolute memory pointer to a buffer.
Look at the module uctypes and the methods uctypes.addressof() and uctypes.bytearray_at().
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How to find the absolute memory pointer to a buffer.
Those deal with absolute addresses, but only of objects created in the MicroPython heap. To program DMA outside of the heap area will require a C module, and also altering the build system to reserve a suitable area. Why does the object have to be outside the heap area? The normal MicroPython approach would be to create buffers in the heap (bytearray instances) and pass their addresses (acquired by the addressof method suggested by @Roberthh) to the C module.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How to find the absolute memory pointer to a buffer.
I might have explained it wrong. The memory area vill ofc be mapped inside the heap. But the address I need to pass to the DMA must be the absolute address since it can only target the entire memory.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How to find the absolute memory pointer to a buffer.
addressof does produce absolute addresses.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.