Code:
HTML:
Code:
Code:
[CODE]
The code is quite big and needs custom hardware, therefore I first try to describe the problem. Hopefully, somebody can give me a hint in the right direction.
General Description:
I have an Interrupt which runs every microsecond, and in fact, must be run every microsecond because it reads data from a hardware ADC. In this interrupt, I copy 4 bytes over to the internal memory. In the main loop, I copy over the data from the internal memory to the Ps RAM to have more time when a network problem occurs (see later). When there is data in Ps RAM available it is sent to the Ethernet stack. In the internal Memory and Ps RAM I have a circular buffer organisation but this should not affect the problem that I have.
Problem: When I use RAM1 as internal memory (allocated on the stack: uint16_t buff[BUFF_CAPACITY]) everything works stable. The execution of the whole interrupt needs ca. 300-400 ns.
But when I use RAM2 with DMAMEM (allocated on the stack: DMAMEM uint16_t buff[BUFF_CAPACITY]) the copying of the 4 bytes inside interrupt needs sometimes up to 2-3 microseconds (usually some nanoseconds are normal). This happens periodically but not often: only a certain times per second. Anyway, this is not acceptable because in this situation the sync with the ADC is lost.
To be true I am not very experienced in embedded topics. I was reading through "Thread: T4.0 Memory - trying to make sense of the different regions". There was a hint that buffering may be a problem with DMAMEM. I tested a modification to startup.c which should disable buffering, but this did not change anything.
Code:
I changed in startup.c
SCB_MPU_RBAR = 0x20200000 | REGION(i++); // RAM (AXI bus)
SCB_MPU_RASR = MEM_CACHE_WBWA | READWRITE | NOEXEC | SIZE_1M;
to
SCB_MPU_RBAR = 0x20200000 | REGION(i++); // RAM (AXI bus)
SCB_MPU_RASR = MEM_CACHE_WT | READWRITE | NOEXEC | SIZE_1M;
Can somebody with more Teensy experience give me a hint: What can be the reason for the high writing times to DMAMEM inside the interrupt? Buffering? Memory organisation? And how to avoid it?
Here is a output of Frank Boesings memory logging functions
Code:
Free Stack: 330980
Free Heap: 12000
FLASH: 97320 1.20% of 7936kB (8029144 Bytes free) FLASHMEM, PROGMEM
ITCM: 80200 81.58% of 96kB ( 18104 Bytes free) (RAM1) FASTRUN
PSRAM: 16 MB
OCRAM:
524288 Bytes (512 kB)
- 413824 Bytes (404 kB) DMAMEM
- 98664 Bytes (96 kB) Heap
11800 Bytes heap free (11 kB), 512488 Bytes OCRAM in use (500 kB).
DTCM:
425984 Bytes (416 kB)
- 94912 Bytes (92 kB) global variables
- 1332 Bytes (1 kB) max. stack so far
=========
329740 Bytes free (322 kB), 96244 Bytes in use (93 kB).
Maximal stack usage: 1332