Recent

Author Topic: PicUtils - Utilities for Microchip microcontrollers  (Read 10137 times)

Edson

  • Hero Member
  • *****
  • Posts: 1301
PicUtils - Utilities for Microchip microcontrollers
« on: August 01, 2015, 12:52:16 am »
PicUtils is a collection of specials routines for helping on developing tools for PIC microcontrollers.

https://github.com/t-edson/PicUtils

Currently it's only for Mid-Range devices (14 bits instruction).
« Last Edit: August 01, 2015, 04:12:02 am by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #1 on: August 01, 2015, 02:28:53 am »
If you add the following line to the assembler code, the program crashes:
Code: [Select]
addwf
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #2 on: August 01, 2015, 04:11:34 am »
It's because the instruction: "addwf" needs  two parameters.

Actually, it crashes with any incomplete instruction, because it has not a complete checking errors routine. The "MiniAssembler" demo is just that, a demo, not intended to be functional at all.

The objective of this library was to be used for a compiler, not for an assembler, but it could be used too, for this function.
« Last Edit: August 01, 2015, 04:14:16 am by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #3 on: August 01, 2015, 04:13:53 am »
I have added to the project demo, some code to check better the syntax, but it's still, a very basic demo.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #4 on: August 01, 2015, 01:23:45 pm »
Microchip omg. The worst platforms ever. Especially dsPIC...

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #5 on: August 01, 2015, 11:22:23 pm »
Microchip omg. The worst platforms ever. Especially dsPIC...

I use dspic, and rather like it. What is exactly the problem?

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #6 on: August 02, 2015, 10:05:23 am »
Quote
I use dspic, and rather like it.
I only recall the horrible memory organization but there were many other problems, which I had to face when writing a bootloader for it, among other things. Things that were so straightforward in other controllers (have been using Renesas, Freescale, NXP, TI). If you like it then so be it, world is diverse. Didn't intend to make a offtopic flame, just noticed the thread and recalled for the horrible pain I had to get through with this platform.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #7 on: August 02, 2015, 12:44:53 pm »
Quote
I use dspic, and rather like it.
I only recall the horrible memory organization but there were many other problems, which I had to face when writing a bootloader for it, among other things.

Well, they are 16-bits devices with more that 64kb in combined flash+memory, so that always requires some special handling. (the upper 32kb of the address space is a kind of window to either ram>32kb or flash). What I really like is the high pincount, and the availability of the whole range of peripherals on one part. (which is great if you want to have a single base board for projects). Speedwise it is average, less than 32-bit, faster than 8-bit, but that should not be a surprise.

Quote
Things that were so straightforward in other controllers (have been using Renesas, Freescale, NXP, TI). If you like it then so be it, world is diverse. Didn't intend to make a offtopic flame, just noticed the thread and recalled for the horrible pain I had to get through with this platform.

It's never good to view a cpu family through eyes shaped only by other vendors. It makes it easy to look over the actual strengths.

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #8 on: August 03, 2015, 01:29:29 am »
Didn't intend to make a offtopic flame, just noticed the thread and recalled for the horrible pain I had to get through with this platform.
Choosing the correct tools for the job in soft- and hardware makes a big difference.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #9 on: August 06, 2015, 12:09:42 pm »
Quote
Well, they are 16-bits devices with more that 64kb in combined flash+memory, so that always requires some special handling.
That is not what I actually meant, I only recall now there was some weird addressing like 3 bytes on every even address in FLASH or so, making a custom bootloader application really a tough job. That addressing was due to some historic reasons and very badly designed.

Quote
What I really like is the high pincount, and the availability of the whole range of peripherals on one part.
That does almost every 32-bit Cortex now, with linear memory addressing and all the powers of the ARM core, CMSIS standard for easy porting between vendors etc.
For my part, never needed more than 100 pins (which e.g. TI Stellaris or NXP LPC parts offer for comparable prices).

Quote
It's never good to view a cpu family through eyes shaped only by other vendors. It makes it easy to look over the actual strengths.
Microchip had free tools as the first vendor, that was their only strength. But some other ppl have different opinion as you, as can be seen e.g. here: http://www.microchip.com/forums/m601857-p2.aspx

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #10 on: August 06, 2015, 02:07:22 pm »
Quote
Well, they are 16-bits devices with more that 64kb in combined flash+memory, so that always requires some special handling.
That is not what I actually meant, I only recall now there was some weird addressing like 3 bytes on every even address in FLASH or so, making a custom bootloader application really a tough job. That addressing was due to some historic reasons and very badly designed.

Ah that. Yes there is something like that, though I can't remember if it is notational (3 bytes in hex to 2 bytes in flash) or not.

Quote
Quote
What I really like is the high pincount, and the availability of the whole range of peripherals on one part.
That does almost every 32-bit Cortex now, with linear memory addressing and all the powers of the ARM core,

(the dspic if you enable the upper memory area to be ram not flash is linear too, there are compiler options for that. Specially if you have little static initialize data this is a good solution).

Quote
CMSIS standard for easy porting between vendors etc.

I don't really care about porting, if you years later have to port because the part is unavailable, reopening development is a problem in all cases. It is not really a decision influencing factor to me, because so easily remedied. If a part is EOL (and that is *RARE* with microchip) If push comes to I drop a couple of hundreds bucks worth of on chips on store, and am good for another 5-8 years.

But most important are the peripherals, I looked not one year ago, and I didn't even come close, specially motor control. How many Cortex parts e.g. have quadrature encoder ? The LPC range looked better than it did 5 years ago though.

Quote
For my part, never needed more than 100 pins (which e.g. TI Stellaris or NXP LPC parts offer for comparable prices).

I mostly use the 144pin part. The generic board is used the most, because we don't turn over that many, (tens an year)  it was cheaper to design in the biggest part (well second biggest, but it only differs in flash amounts) than have multiple boards to save costs. The P&P for extra prints was already more expensive.

Generic boards however also in general like remappable I/O (which was also was a bit scarce in LPC iirc)

The CPU still isn't the most expensive part on the boards, high speed optocouplers (for quadrature) usually are.

Admitted we also use the 144pin part because it also has the highest number of remappable I/O.

That said there are also points with concern. CPU speed is not really an issue, but recently we added a IP stack IC, and SPI speeds could be higher.  (something like 15mbit for the one hardwired to pins, 10-8 for the remappable ones).

Luckily it is all under DMA (even command and control of the IP stack IC, one of the reasons to select it, e.g. the 32-bit PIC do much better there, but are motorcontrol is not available, and we don't have a major problem to begin with)

Maybe a major redesign will go a different direction, but this design has quite some mileage yet, and not really problems (incremental revision from F to E about two years ago)

Quote
Quote
It's never good to view a cpu family through eyes shaped only by other vendors. It makes it easy to look over the actual strengths.
Microchip had free tools as the first vendor, that was their only strength. But some other ppl have different opinion as you, as can be seen e.g. here: http://www.microchip.com/forums/m601857-p2.aspx

I know that is the popular opinion, but IMHO it is wrong or at the very least oversimplified. It all depends on what you want. Many of the popular opinion consider raw ALU speed to be the most important. Some from the other camp bitbanging speed (dspic can toggle a pin at half the CPU freq).

Mine is probably colored by motor control (and then specially quadrature) needs. Some people prefer one part (we mostly, except for the (TCP/)IP engine) , some are more amenable to add additional parts.

Davy Jones has the right of it: https://www.youtube.com/watch?v=DBftApUQ8QI
« Last Edit: August 06, 2015, 02:09:07 pm by marcov »

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #11 on: August 06, 2015, 03:12:50 pm »
Quote
But most important are the peripherals, I looked not one year ago, and I didn't even come close, specially motor control. How many Cortex parts e.g. have quadrature encoder ?
Well I can understand that, if you needed special peripheral directly in the uC. Then you probably had no other choice at that time.
(one company I worked some time ago for, did the whole motor control thing externally, in a FPGA/CPLD, and used a TI part as uC)

Quote
I don't really care about porting
We care for that, because the need for redesign was a reality we had to face several times already (although not directly with the uC, and yes once it was a BIG problem for us to buy remaining parts, as IMO no one has the chance to follow all EOL announcements for his part lists).
Either way, it is always better to have this work most simplified, when the need for porting comes. And in case of an ARM Cortex it is almost always very simple (if you don't use those special peripherals).

Quote
I know that is the popular opinion, but IMHO it is wrong or at the very least oversimplified.
This was only a phrase our (almost entire) devteam has used as a joke upon mentioning Microchip.


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #12 on: August 06, 2015, 05:50:07 pm »
Either way, it is always better to have this work most simplified, when the need for porting comes. And in case of an ARM Cortex it is almost always very simple (if you don't use those special peripherals).

I mostly use peripherals, specially the quadrature encoder to sync everything to the machines cadence. Or at least I can't imagine much code being unmodified if peripherals change.

Peripherals, specially when remappable, are a boon for projects. If you just have a design in for something simple it doesn't matter much, or just make do with a small daughter board to a generic solution, and you because the faster actions are suddenly hardware, latencies are better and there is always enough CPU for the inevitable wishlist items

Anyway, it seems the portability is mostly to solve a problem with those vendors, rather than something universal.

« Last Edit: August 06, 2015, 09:22:39 pm by marcov »

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #13 on: August 07, 2015, 09:20:06 am »
Quote
I can't imagine much code being unmodified if peripherals change.

Is true if you use special peripherals or specific, target/vendor bound features of common peripherals. We already many years focus on HAL whenever possible, doing specific stuff externally (e.g. energy measurement). In our case, we use only common peripherals like UARTs, I2C, SPI, Ethernet, ADC, PWM, timers, FLASH IAP. And we use vendor HAL libraries for that. One has always to study the new datasheet but if the HAL library is well documented the time spent on it is quite short. The CMSIS library eases the most difficult things about system timing etc. Recently I've ported one project from NXP LPC to FRDM K64 and it was a matter of ca 2 days. But as said, we don't use any specific peripheral and do specific things externally. We altready incorporate this into the original product design.

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicUtils - Utilities for Microchip microcontrollers
« Reply #14 on: August 12, 2015, 12:46:33 am »
PicUtils 0.2 is available.

https://github.com/t-edson/PicUtils

PicUtils is a collection of specials routines for helping on developing tools for PIC microcontrollers. Currently it's only for Mid-Range devices (14 bits instruction).
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018