Jump to content
 
  • 0
dvvrao

Simulator, UART with DMA, PIC32, MPLAB X IDE

Question

Does the simulator for PIC32MX470F512L support UART with DMA operation? 
I wrote a program that transmits a character using UART with DMA, but does not work. 
I used Dynamic USART driver with Buffer Que Data Transfer model using DMA.

PFA the package file of the project.

Please let me know if there is any thing wrong with the code or harmony configuration.

usart_loopback.zip

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 1

Please feel free to upload code, pictures, videos, whatever you need to make it clear over here, that is the reason we made this forum, to overcome exactly that problem, so thank you for doing that!

George writes the simulator, so there is no better person to help you!

Share this post


Link to post
Share on other sites
  • 0

Quick look I see that DMA is supported and so is UART, so I would expect that this would be covered. Will get some time on the weekend to try this out and will let you know if I find something interesting.

I am sure there are others on here who have more experience at this and can just throw up an answer though 🙂

Share this post


Link to post
Share on other sites
  • 0

I had to create this post here to upload my code and mention the link on that forum.

There i could not upload the code as it was exceeding the 500KB limit.

When i get a solution for my problem in that forum i will update here.

Share this post


Link to post
Share on other sites
  • 0

Of course, the simulator may be fine. It may just be Harmony that's not implementing USART via DMA correctly...

 

  • I Agree 1

Share this post


Link to post
Share on other sites
  • 0

Follow up: From George's response on the Microchip Forum this was verified as a bug in the simulator DMA implementation. 

He also posted that this "should" be fixed in MPLAB X 5.20, which means it may end up only being included in 5.25

Response on the forum was this:

 
Quote

 

Re: Simulator, UART with DMA, PIC32, MPLAB X IDE 3 days ago (permalink)
Thanks, that was the missing piece of information that I needed.  I am now convinced the simulator is "broken".  I will write a trouble report to get this fixed.  Unfortunately I would guess this gets fixed in 5.25 not 5.20 😞 More unfortunately, I do not think there is a workaround that can be used for the current version of MPLAB X that you are using.

For those of you who enjoy observing the sausage being made (you know who you are...):  The simulator's DMA peripheral is writing directly to memory instead of to the SFR wrapper objects the simulator uses emulate SFRs.  The simulator's UART is faithfully observing (ala gang of four Observer pattern) the TXREG SFR for notification of a new value being written.  Unfortunately that notification never comes because the DMA did an end-run around the SFR by writing directly to memory.  

This all works perfectly when you use the DMA in the other direction, ie receive a bunch of characters and copy them to a memory buffer.

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


 


  • Popular Contributors

  • Similar Content

    • By Orunmila
      I am trying to use a linker script with MPLAB-X for my PIC32 project but for some reason the script is not being passed to the linker at all. I expected that all I had to do was add the .ld file to my project, typically by placing it in the "Linker Files" virtual folder in MPLAB-X in my project. I did this and the linker script is being ignored by the linker.
      This is one of those $100 questions (if you know the story of the mechanic asking $100 for knowing where to hit ...).
      So my question is how do I get MPLAB-X to use my linker script which I have added to the PIC32 project?
    • By Orunmila
      I have a MPLAB-X project which uses a loadable (it is combining my program with a bootloader which is in another project). 
      I need to compile this project from the command line for CI automation. For the entire build process every command executed is nicely printed in the build window, but for the loadable it claims to be using Hexmate, but the command line to execute it is not shown at all.
      Can anyone help me with the syntax using Hexmate to get the same behavior as adding the Loadable from MPLAB-X?
    • By N9WXU
      I was reviewing a Cypress data sheet for the CYW4390 and saw a line in the UART chapter saying that the total baud rate error budget for both ends had to be less than 2%.  With a large dependence upon internal oscillators these days, it seemed a good time to discuss these error budgets.  Is 2% reasonable or conservative?
      First here is a quick back of the envelope calculation for link budget for UARTS.  I will assume "perfect" rise & fall times, and 8, none, 1(8n1) framing.
      There are a total of 10 bits in a byte with 8n1 so each bit is 10% of the total byte time.  If your link budget is larger than 10%, you will miss a bit.  BUT WAIT... all UART implementations I am aware of try to sample in the center of the bit.  Generally, this is done by oversampling 16x and using the center 3 samples as a majority detect.  If you consider that slipping the byte time by 1/2 a bit time will cause a missed bit, our link budget is now 5%.  If you KNOW you are talking to a PERFECT receiver, then you can accept the entire 5% error.  (Of course, you can assume your design is perfect and pass the blame to the other side, but then you would not be reading this.). I am sure that perfect transmitters & receivers are not possible, so we shall reasonably accept 1/2 the responsibility for the link budget, making our baud rate error specification 2.5%.
      Hmm.  Something still seems rotten.  The data sheet states that the TOTAL budget is 2%.  Our envelope scribblings say 5%.  What gives?
      Here is a good writeup by Maxim Integrated (https://www.maximintegrated.com/en/app-notes/index.mvp/id/2141) that adds some more details.  Essentially, you have an uncertainty of ±1 sample-time detecting the START bit and a terrible link would have a 50% chance of detecting the midpoint of the stop bit.  The short of the story is a ±3 sample-time error budget out of a needed 152 sample-times (160 sample times less 1/2 a bit time) or ±2% error budget for the link.  That assumes you are over sampling 16x.  On a PICmicrocontroller, the UART has a high speed mode (BRGH = 1) which changes the sampling rate to x4 instead of x16.  This can have a profound effect on the error budget due to the ±1 bit sampling uncertainty.
      So here are a few recommendations:
      1) Always use the MAXIMUM sampling rate available in your UART.
      2) Consider a crystal (20ppm) or a resonator (0.5%) or if you must use an internal oscillator, I hope your temperature & power supply is stable so your oscillator accuracy is good.
      3) Consider using the auto baud features and internal oscillator tuning features if they are available in your controller.
      Good Luck
×
×
  • Create New...