Hot!Modifying older libraries to run with PIC32MX174 - has anyone done this already?

Page: 12 > Showing page 1 of 2
Author
VJM
Super Member
  • Total Posts : 196
  • Reward points : 0
  • Joined: 2013/04/16 10:09:35
  • Location: 0
  • Status: offline
2018/03/06 09:04:50 (permalink)
0

Modifying older libraries to run with PIC32MX174 - has anyone done this already?

I am currently running out of processing power on an instrument controller using a PIC32MX170.  The problem is the time available for performing some calculations on a sensor input, not memory or other capabilities.  I would like to change to the 174 device, as this has a higher clock / is a drop-in replacement, and would solve the problem (I think) without significant software re-write.  The original code is written using the older non-Harmony libraries, as this approach offered significant code re-use and speed in development.  They also were proven to work in this application...
Has anyone modified the older libraries to support the 174 device?  The differences appear to be in the oscillator module, and in the addition of a deep-sleep WDT.  A quick look in other areas indicates that the headers have been changed and some word accesses changed, but this appears manageable.
Am I being unreasonable or silly?  I would appreciate comments or thoughts from those more expert in this area before embarking on a more in-depth review, and it would be great if someone had already had and solved this problem.
Many thanks in anticipation,
VJM
#1

22 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 16580
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/06 09:53:07 (permalink)
    0
    Are you talking about PLib aka the Peripheral Libraries?
    #2
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/06 09:59:02 (permalink)
    0
    Yes; apologies if this was not clear.  Basically, not Harmony.  The older libraries that I have debugged and used successfully for some years (in XC32/pic32-libs/peripheral).  I use an older and very stable compiler (V1.40), as I have a licence and it has proved excellent.  I do not use the legacy libraries in this framework.
    VJM
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 16580
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/06 10:25:00 (permalink)
    3 (1)
    There should be source code for the libraries.  You would need to port it .  I have not seen anyone Post that they have ported the libraries.
    #4
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/06 12:03:41 (permalink)
    0
    Thank you - I think that it is possible, despite the significant differences.  The main areas requiring porting / change seem to be as I stated.
    I will take the code and compile it to against the different processor, and see what happens (errors reported in the library files).  I will then modify the library code to clear the issues raised, focusing on the routines I actually use...  Then add relevant bits for the oscillator etc., if needed, but I suspect that the pragmas will take care of that side of the port.  This will hopefully create a 'new' compiler environment, which I should be able to use for the 174!
    Thanks again for your interest.  I appreciate that this is probably a low interest project...
    VJM
    #5
    daveX
    Starting Member
    • Total Posts : 39
    • Reward points : 0
    • Joined: 2013/07/20 15:20:21
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/06 21:50:51 (permalink)
    0
    Please post your progress. 
    I will run out of horsepower with MX575 before to long and I have no intention of moving to Harmony.
    A successful example would be a great thing.
    Dave
    #6
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/06 23:58:47 (permalink)
    0
    Dave,
    Thank you for your message.
    I will assess the work required, as there are pressures on my time.  Currently, I have created a second copy of v1.40 of XC32 (this is the version that I use, I'm afraid), had fun and games with disabling the read-only status of the files (not fully resolved - may be a Windows issue, looking at problems reported on the internet), and compiled my code.  The only way that I see to edit the files consistently is to use notepad++ (or equivalent) as the main editor, as editing the files within mplabx does not seem to allow me to store the edited versions consistently...
    My intention is to look for the bit definitions in the code for elements that are different, and to change the routines thus detected appropriately, creating a dedicated compiler environment for the 174.  My focus will be on the oscillator and watchdog initially, as the configuration words seem to be handled well by the appropriate window in mplabx.
    This may prove to be too time consuming, as mentioned before, but I would be delighted to share any experiences.
    I will probably crash and burn, but I will have a go as time permits.
    I am sure that expert members of this community will have advice, or views on the feasibility and actual sense of this work...  I am disappointed that we are being forced into Harmony (I will change to ARM processors before going there, as I find it too constraining and cumbersome), but I understand the commercial 'sense' of this decision by Microchip.
    I suspect that I am a little mad!
     
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 16580
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/07 00:35:18 (permalink)
    0
    With harmony it is possible to create a shell project and just use harmonys version of PLIB. You can do that an not use the other harmony drivers.
    #8
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/07 00:54:01 (permalink)
    0
    Thank you for this clarification.  It is indeed an option.
    My challenge is that I have extensive code that drives scientific instrumentation, and changing to a different framework does not appear attractive.  I appreciate the point that you make, but I am a little cautious in changing to libraries that are unknown and that may have their own set of issues.  I prefer to stick to the devil I know, with known workarounds that I have developed through use.
    I am trying to discover if the particular oscillator and watchdog are used in other microchip products, as it may be possible to change the processor-specific definitions in the libraries to point to the appropriate, proven code...
    I am also struggling to get at the code for harmony libraries to see what I can learn from these...  The file layout is not obvious, but perhaps I am missing something.
    I will probably have to stick to the 170 device and to figure out better algorithms to perform the processing task that I need to complete between data samples, or to accept lower performance by processing every other sample...
    Best wishes,
    VJM
    #9
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/07 02:24:30 (permalink)
    0
    With changes to system.h, rtcc.h, osc.h in pic32mx\include\peripheral (at the moment just inserted a warning that work needs to be done in these locations), I can get the code to compile and build.  I am using 
    #if defined (__32MX174F256B__)
     #warning This function is not yet defined for the 174 device system.h line 365 (or similar)
    #else ...
    to select this code if the 174 is used as the processor. Re-selecting the 170 processor seems to build cleanly, and to run, as before.  I do not use the functions that require modification, I think...
    Much more required to deliver a library, but this might get me off the ground if I use the configuration bits and do not play with the oscillator.
    #10
    maxruben
    Super Member
    • Total Posts : 3292
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/07 04:00:42 (permalink)
    0
    Have you tried to optimize the code with the calculations? That might be easier.
     
    /Ruben
     
     
    #11
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/07 04:09:39 (permalink)
    0
    Dear Ruben,
    Thank you for your comment.
    I find that the C compiler is pretty good at optimising, and my assembler is not good...  Samples are at 1ms intervals, but there is quite a lot going on in parallel.
    However, you are right, and I will look again.  The way the project is progressing (it is a research project at a US university), there is a likelihood that the algorithm will change again, and I would like to have some 'head room'.  We are also at a point where we are about to commit to manufacturing more of the boards, and the attraction of a 25-33% improvement in core capability is high, if we do not have to delay or rewrite too much code.  Hence this investigation!
    As usual for a university, funds are tight, so redesigning the board for a higher-end processor is unattractive.  It is easy to be wise in retrospect!
    Best wishes,
    VJM
    #12
    maxruben
    Super Member
    • Total Posts : 3292
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/07 04:43:48 (permalink)
    0
    VJM345
    I find that the C compiler is pretty good at optimising, and my assembler is not good...  Samples are at 1ms intervals, but there is quite a lot going on in parallel.



    Hi, I am not talking about compiler optimization (which can of course also help). I am talking about how to structure the software and handle calculations. E.g. using fixed point instead of floating point, lookup tables, not using more precision than needed and so on. This could easily get you a 10 times or faster code while changing the hardware would get you, what, double the speed? This is assuming that the code is already not (manually) optimized.
     
    Can you show your calculation code and your requirements?
     
    /Ruben
    #13
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/07 07:09:02 (permalink)
    0
    Dear Ruben,
    Thank you for the clarification.  You are right in suggesting that improvements can be made in this area through the techniques that you mention, and I am indeed looking at this.  Due to academic sensitivity, I am not at liberty to share the problem or code at this stage - I hope you understand.  The interest is in applying fuzzy logic techniques and AI to a fast responding control system, and in evaluating earlier results to change loop parameters in real time.
    The underlying intent is in making as much horsepower available as possible in the new boards - hence the interest in the 'free' change from 50 to 72 MHz in going from the 170 to the 174, as no hardware changes would be needed.
    I also like investigating 'challenges' to ensure that I understand the underlying information before making decisions - which is at the heart of this investigation.
    For interest, I now have the code fully compiled with no warnings for the 174 (I had a couple of spare hours this morning), and can see no particular problems now that I have modified the osc, rtcc and system headers in the old libraries.  I have not added the new features in the 174 yet, and am not sure that I need to particularly.
    The bottom line is that you are spot on with your analysis, and that I can and should solve the challenge through improvements in the algorithmic area.  This has become an 'interesting' investigation more than a 'necessary' one - I shared it in case someone else had already solved the problem, as I am not a fan of Harmony - possibly in error!
    My thanks again,
    VJM
     
    #14
    maxruben
    Super Member
    • Total Posts : 3292
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/07 11:58:46 (permalink)
    0
    I do understand regarding code sharing. Although I think you would have more to win than to loose by sharing.
     
    Does the increase in clock speed require more wait states for the flash?
     
    Sounds like a fun project. Good Luck.
     
    /Ruben
     
     
    #15
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/08 01:50:13 (permalink)
    0
    Good point - I will check on the wait states.  The project is distributed, so code sharing agreement is difficult...
    Thank you for your thoughts and encouragement! I will update when I test the revised libraries on a 174; probably next week, if I'm lucky.
    VJM
    #16
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/08 23:09:15 (permalink)
    0
    Quick update - I have now had a chance to check through the 174's data sheet in more detail.  The wait state potential issue is more than countered by the cache module that this processor includes, which should give a significant performance improvement.
    I have analysed (first pass) the register differences, and come to the following conclusions (which may not be fully correct) - shared for interest (I am sure that Microchip could help if they so wished...):
    Reset - 174 has additional bits that need to be added to the code
    Interrupt controller - no differences
    Oscillator - quite different; significant code change required, but relatively simple... New modes.
    DMA modules - the same
    Cache module - only on the 174; ignore in library?
    USB-on-the-go - same module
    IO ports - identical
    Timer 1 - some differences (external clock selection)
    Timers 2-5 - same
    Watchdog timer - significantly different; code re-work required
    Deep sleep watchdog timer - only on 174
    Input capture module - the same
    Output capture module - the same
    SPI module - the same
    I2C module - the same
    UART module - some differences; enhanced on 174
    PMP - enhanced on 174, but not clear what is really available; minor errors in documentation?
    RTCC module - some enhancements; add to code
    ADC - the same
    Comparator - the same
    Comparator reference - the same
    high/low voltage detect - 174 only.  Not sure about this one...
    Charge time measurement - the same
    Power saving - enhanced on 174 with deep sleep; disable module nits appear the same
    Special features - some differences - not sure how much this is used in library; requires further investigation
     
    Will now look at c code in the library as time permits - just an interesting project!  If anyone has further comment or interest, please let me know.
    VJM
     
    #17
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/09 01:42:10 (permalink)
    0
    Just to clarify my confusion on PMP...
    The 174 document (DS60001404A - which is labelled Advance Information...) indicates that register 22-6 (PMWADDR) is only used when DUALBUF is set.  This is PMCON<17>, which is shown as not used in the definition of the PMCON register (Register 22-1).  Help!
    I think that I will ignore these additional registers at this stage in my consideration and leave PMP alone.
    Can anyone clarify?
    VJM
    #18
    DavidBLit
    Super Member
    • Total Posts : 1574
    • Reward points : 0
    • Joined: 2012/02/18 13:08:48
    • Location: The Land of Confusion
    • Status: online
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/09 07:34:24 (permalink)
    0
    Beware of cache coherency issues if you're using DMA.

    Yeah, "//Code and stuff".
    #19
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Modifying older libraries to run with PIC32MX174 - has anyone done this already? 2018/03/09 23:59:12 (permalink)
    0
    Thank you - you make a valid point.  I hope that the existing DMA libraries will handle this, as they operated successfully on larger devices with cache, but I will have a quick look.  Rapidly getting out of my depth, though I understand the principles!  I use DMA for serial ports, so I need to be careful...
    VJM
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2018 APG vNext Commercial Version 4.5