PinguinoIDE / pinguino-libraries

Pinguino librairies, keywords and other useful files.
24 stars 27 forks source link

Fix USB BULK buffers on 16F1459 and simplify code #22

Closed kh90909 closed 6 years ago

kh90909 commented 6 years ago

The USB bulk code was not updated for 16F1459. This leaves the RX and TX buffers outside of dual-port RAM, so it doesn't work. This commit relocates the buffers to the right location. Instead of using absolute addressing, the __section() specifier is used to give the compiler the flexibility to place the buffers anywhere in the given section. This change requires commit 611afb4 to pinguino-ide, which updates the usbram5 section to the correct processor-specific memory ranges.

This commit also updates the CDC code to allocate those buffers in the same way.

rblanchot commented 6 years ago

Hi, Did you test this change ? The Dual-Port RAM is not located at the same address for all PIC. For most of them it's in the range 0x500 - 0x5FF For the 16F145x family the range is 0x2000 - 0x21FF
For the 18F1xk50 family it's 0x200 - 0x2BF It seems you placed all the RX/TX buffers (BULK and CDC) in __section("usbram5") which is in 0x500-0x5FF or did I miss something ? Regards, Regis

kh90909 commented 6 years ago

I also submitted a pull request to pinguino-ide (PinguinoIDE/pinguino-ide#92) which changes usbram5 for the 16F145x and 18F1xk50. Take a look at that pull request and see what you think - it might need some work to make it more future proof.

I have tested on 16F1459 and can confirm it works there. I don't have any of the other PICs to test.

rblanchot commented 6 years ago

Alright. Thanks. I'll make a test tomorrow.