So, i was wondering, since now we have quite a few PIC 18F chips with DMA support, would it be possible to implement DMA usage (using for example a 18F47Q43 instead of Q10) on cow basic's HSerReceive command?
And does the usage of DMA would have a big impact in execution time of the command?
Last edit: ikonsgr74 2024-11-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm aware of these demos, we have already discussed the DMA subject in more general, a couple of years ago, but what i was hoping for, is for an update of the HSERRECEIVE cowbasic command itself, without needing to alter the existing code of our cowbasic programs.
I was thinking something like an "alternative" code path for the HSERRECEIVE command: Whenever a PIC MCU with DMA support is used in cowbasic #CHIP directive, every time an HSERRECEIVE command is shown in source code, the compiler would choose an alternative code that will use DMA ;-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can write a DMA receive routine but I am not sure how you would manage. The serial interrupt buffer ring is my go to method to handle incoming serial.
I guess The DMA serial in routine could put the coming data into a buffer ring ( an array ) and then use the DMA counters to process the buffer ring.
NOTE: the DMA would ONLY WORK on a specific message size. You would need to ensure the message size is always the same size.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Exactly, i'm using the same method too, an input buffer ring and an interrupt: On Interrupt UsartRX2Ready Call readUSART
The readusart routine deals with the input buffer ring:
But, the "core" of this routine, is the assignment in the input buffer, of the byte received from HwSerial port, using cow basic's HSerReceive command! So, what i proposed was to "encapsulate" any DMA usage inside the HSerReceive command code itself! Do you think this is feasible, and will it help to speed up things?
btw, i suppose the message size in this case will always be 1, as we only receive one byte at a time...
Last edit: ikonsgr74 2024-11-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Any solution would be specific to each implementation. Incrementing the buffer pointer and managing the state may take more code than the call to HSerRecieve.
But, it should be possible. Give it a try.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So if i get it right, you say that even if HserReceive command supports DMA (and is faster than the existed non DMA command code), practically you wil not get any great speed advantage, because the code for incrementing the buffer pointer and managing the state ,takes more time?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think a reference AppNote would help us understand. Have a search to see if you can find some reference.
I am not clear on how a DMA read operation would work. Fixed packet size, error handling, pointer management. A reference implementation from Microchip would really help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
From asm files, i saw that the "core" of the hserReceive command execution is an rcall to a HSERRECEIVE322 routine (PIC used is 18F47Q10):
So, i was wondering, since now we have quite a few PIC 18F chips with DMA support, would it be possible to implement DMA usage (using for example a 18F47Q43 instead of Q10) on cow basic's HSerReceive command?
And does the usage of DMA would have a big impact in execution time of the command?
Last edit: ikonsgr74 2024-11-11
There are DMA demos that show how this works. The performance is stunning.
Also, do a search of this forum for the DMA posts relating to the DMA work I dis.
Let me know if you have issues finding anything.
I'm aware of these demos, we have already discussed the DMA subject in more general, a couple of years ago, but what i was hoping for, is for an update of the HSERRECEIVE cowbasic command itself, without needing to alter the existing code of our cowbasic programs.
I was thinking something like an "alternative" code path for the HSERRECEIVE command: Whenever a PIC MCU with DMA support is used in cowbasic #CHIP directive, every time an HSERRECEIVE command is shown in source code, the compiler would choose an alternative code that will use DMA ;-)
You can write a DMA receive routine but I am not sure how you would manage. The serial interrupt buffer ring is my go to method to handle incoming serial.
I guess The DMA serial in routine could put the coming data into a buffer ring ( an array ) and then use the DMA counters to process the buffer ring.
NOTE: the DMA would ONLY WORK on a specific message size. You would need to ensure the message size is always the same size.
Exactly, i'm using the same method too, an input buffer ring and an interrupt:
On Interrupt UsartRX2Ready Call readUSART
The readusart routine deals with the input buffer ring:
But, the "core" of this routine, is the assignment in the input buffer, of the byte received from HwSerial port, using cow basic's HSerReceive command! So, what i proposed was to "encapsulate" any DMA usage inside the HSerReceive command code itself! Do you think this is feasible, and will it help to speed up things?
btw, i suppose the message size in this case will always be 1, as we only receive one byte at a time...
Last edit: ikonsgr74 2024-11-11
OK. That approach of the buffer makes sense.
Any solution would be specific to each implementation. Incrementing the buffer pointer and managing the state may take more code than the call to HSerRecieve.
But, it should be possible. Give it a try.
So if i get it right, you say that even if HserReceive command supports DMA (and is faster than the existed non DMA command code), practically you wil not get any great speed advantage, because the code for incrementing the buffer pointer and managing the state ,takes more time?
I think a reference AppNote would help us understand. Have a search to see if you can find some reference.
I am not clear on how a DMA read operation would work. Fixed packet size, error handling, pointer management. A reference implementation from Microchip would really help.