Why should I use ARM ? lazarus / 8-Other ---------------------------------------------------------------------- jack616 · 2012-08-01 11:26 For some years I've been developing with PIC chips but have become uneasy as ARM is both british and a viable alternative - maybe... generally I prefer british tech if I can get it but it has to be supportable. Thats the criteria - supportable. The thing I love about PIC is the incredible support from the manufacturer etc. After going to trade shows and looking at ARM suppliers everything appears to be very fragmented and VERY amateur by comparison. I'm asking here because I'd be interested to know if using FPC/Laz would provide a good and well supported route to using embedded ARM chips. I'd welcome any comments and especially pro experiences on this. Is my perception of fragmented support accurate? ---------------------------------------------------------------------- Leledumbo · 2012-08-01 11:57 The only ARM processor I use with Lazarus/FreePascal is the one from my Android phone, where I write applications for. I wonder what kind of support do you mean, from Lazarus/FreePascal side or who? And could you be more clearer about the "fragmented support"? ---------------------------------------------------------------------- Laksen · 2012-08-01 12:15 ARM is a core that is usually licensed by many different microcontroller companies, so you have the benefit that you can always move most of your code to another manufacturer if one should deprecate a certain chip, or go bankrupt. Microchip is the only manufacturer of PIC chips, so if they go down you are stuck. With Microchip's move to MIPS with the PIC32 you might have an easier time(or even just a maybe possible time) to use FPC on it, but before that they've used some peculiar compiler-unfriendly architectures, so you were stuck with their expensive homemade tools or other non- mainstream compilers. ARM is so widespread that you'll find free quality tools everywhere. What do you mean when you talk about support? ---------------------------------------------------------------------- avra · 2012-08-01 13:35 Using Lazarus for ARM Linux is not that hard, but accessing GPIO, SPI, I2C and similar can be painful and code looks ugly because of direct register names or long sometimes cryptic function names. Custom wrapper around that is unavoidable. Using ARM without Linux for the same thing is even harder. You might ease yourself if you buy cheap mikroElektronika Pascal compiler for ARM, but it is still not as bug free as we would like. ---------------------------------------------------------------------- Knipfty · 2012-08-01 15:00 Old Joke:  Why aren't the Brits any good at building semiconductors? Answer:  They can't figure out how to make them leak oil... Sorry, but I couldn't resist. ---------------------------------------------------------------------- jack616 · 2012-08-01 15:04 hi  thanks for the replies. I will try to expand - I'm not concerned about single sourcing from microchip. It isnt really different to ARM - from my understanding they originate from one source anyway. What if that went bust? PIC is far more widespread than ARM. By fragmented support  - when I asked a question  at one stand at a trade show I was told to go to another company - sorry - I forget the question - (very helpful sounding but not really what I need) anyway it just seemed wrong at the time. This led me to look closer. I didnt like what I found. To compare the way ARM is provided - look at some PIC examples: Microchip provide an offline database chip selector thats a dream to use - it can link to the web site directly accessing data sheets - errata and masses of design notes and hints - all well documented with code and examples. If you dont want to use that - you can do it online and everything is right at hand including accessory suggestions etc. for every item they make - all nicely cross linked - specs and pricing. As far as I could find there is nothing even starting to do that for ARM (show me I'm wrong - I'll be delighted) For PIC everything is all in one place including manufacturing/chip masking etc  support - easy clear pricing etc They even shipped me just 2 surface mount chips in 48 hours FOC from their Asian supply direct because I couldnt get them locally - again could I expect similar sort of support for ARM - if so where from? Especially considering I'm only an occasional customer and not even high volume? As far as I could find  - that sort of infrastructure and support just doesnt exist for ARM (again - delight me) Fragmented manufacture of a core design doesnt seem to lend itself to that level of support from what I've seen. Microchip just seem to have their act together in terms of support. A compiler for a PIC will be based on modules in the chip - you just need one compiler for any chip (I use mikroelektronica C - again great company I know also supports ARM )  Is that the same compiler style for ARM or does each manufacturer require different compilers? IE Would I get stuck trying to use FPC/laz if I changed to different ARM chips?  My research suggested I needed different C compilers - is that correct still and how is that affecting FPC/laz if so? I guess I just feel comfortable with microchip because any question at all can be resolved in one place - quickly and with ease about any aspect of design and use of the chips. If I could use FPC/laz as a compiler for any ARM chip that would at least be a good start. And I'd love to be able to use lazarus for both desktop and embedded work.   The comments by avra about SPI and I2C tend to be very offputting on their own. I think that alone is a deciding factor for my use of FPC. ---------------------------------------------------------------------- jack616 · 2012-08-01 15:07 Quote from: Knipfty on August 01, 2012, 05:00:37 pmOld Joke:  Why aren't the Brits any good at building semiconductors? Answer:  They can't figure out how to make them leak oil... I always thought it was because they were bribed into emigrating to america so the USA could pretend it has a modicum of intellectual capacity? ---------------------------------------------------------------------- Knipfty · 2012-08-01 15:56 The world may never know... ---------------------------------------------------------------------- KpjComp · 2012-08-01 16:25 QuoteWhat if that went bust? PIC is far more widespread than ARM. I doubt Microchip will ever go bust.. But were do you get the PIC is far more widespread than ARM from, considering ARM is in practically every mobile phone / router / NAS drive, the list goes on. From Arm's website -> With more than 25 billion processors already created From wiki -> Microchip announced on September 2011 the shipment of its ten billionth PIC processor. I think people forget ARM chips have been around for a long time now, I used to have an Acorn Archimedes powered by one, fantastic little machine at the time.  Although then it was more known for the RISC tag, than ARM. ---------------------------------------------------------------------- KpjComp · 2012-08-01 16:39 QuoteAnswer:  They can't figure out how to make them leak oil... Yes were not good at that.  That's why we leave that sort of stuff to big American companies like  Halliburton & Transocean.   Who just make shoddy equipment that fails. ---------------------------------------------------------------------- jack616 · 2012-08-02 11:56 Indeed ARM is limited to being in many mobile phones and some net routers as you say. PIC's are in every washing machine, telephone, door chime, microwave, light dimmer, and on and on and on. PICs are literally everywhere. Ignore the marketing and do the math. Theres a big difference between "created" and "shipped" I'd say the Archimedes is a bad example to bring up. It died as a result of having an ARM chip. Both have good tech specs. PICs also have a modular design that allows all sorts of variants ARM can't match because of the business model.  This makes Microchip far more stable in the long term than ARM. But that point is moot anyway. The real point is - support is the key factor. Comments here just seem to confirm my feeling of ARM fragmentation and decision to stick with Microchip which is not what I wanted. ---------------------------------------------------------------------- marcov · 2012-08-02 12:23 Quote from: jack616 on August 02, 2012, 01:56:03 pmIndeed ARM is limited to being in many mobile phones and some net routers as you say. PIC's are in every washing machine, telephone, door chime, microwave, light dimmer, and on and on and on. PICs are literally everywhere. Ignore the marketing and do the math. Theres a big difference between "created" and "shipped" (moreover, while ARM sales are huge, if you deduct the number used by very big companies (like the various mobile vendors, but also normal electronics and computer companies like Linksys, Zyxel and Synologic), how many are really used by people in the same situation as you? QuoteI'd say the Archimedes is a bad example to bring up. It died as a result of having an ARM chip. Things rarely fail for technical reasons, and even rare because of just one reason. QuoteBoth have good tech specs. PICs also have a modular design that allows all sorts of variants ARM can't match because of the business model.  This makes Microchip far more stable in the long term than ARM. But that point is moot anyway. PIC is also closer to a 1instruction 1 cycle model (though not entirely, branching is often also a cycle extra because of prefetch flush), at least the 8-bit (PIC12..PIC18) and 16-bit (PIC24,*33) series. Don't know about the 32-bit series. I've used PIC18 in the distant past, and now use dspic33. QuoteThe real point is - support is the key factor. Support, regular updates to the product lines, and many devices to pick from. Microchip is also good in keeping device count down. Only parts that require higher voltages (then 5V) require additional chips. For the rest, flash, memory etc, is all integrated. QuoteComments here just seem to confirm my feeling of ARM fragmentation and decision to stick with Microchip which is not what I wanted. Also keep in mind that "being also ARM" does mean you have a valid second source for a certain part. The other ARM might be a different generation, not available with the right periphery, require additional chips etc. ---------------------------------------------------------------------- KpjComp · 2012-08-02 12:53 QuoteTheres a big difference between "created" and "shipped" Eh!!,  why would anybody make a chip that never got shipped.  Are you saying that there has been 15 billion more Arm chips made but not used?.  I think PIC has a much bigger following in the hobbyists market, but ARM is certainly not small. QuoteIt died as a result of having an ARM chip. Well it never had an ARM chip, it had a RISC chip like I said.  ARM came later as a result of the RISC chip.  This is my take on it, Acorn were useless at selling into the business sector, and made the big mistake of concentrating on the educational sector.  And what makes your comment even odder, is from what I can gather PIC chips are now RISC anyway. QuoteComments here just seem to confirm my feeling of ARM fragmentation and decision to stick with Microchip Not really sure what you wanted.  As you have found out, ARM don't make there own chips, so you are correct they will be fragmentation.  But I wouldn't say there is limited documentation, or how else how do you think FPC dev's managed to make a compiler for them.  From what I can gather too, there is a much bigger/better toolchain for ARM then there is for PIC too, so for ease use it may even be better for you. Saying this, if PIC is something you feel comfortable with, then I'd say there is no rush to change. ---------------------------------------------------------------------- picstart · 2012-08-03 02:03 I have used PIC's for 20 years. I see the PIC as software controlled hardware with emphasis on the hardware peripherals. PIC's don't need an OS and are rarely multi-tasked. PIC's survive harsh environments ..inside washing machines etc. PIC's have extremely predictable timing since every instruction except goto takes  the same number of clock cycles and goto takes exactly twice as many. The de-facto language is C.  Lazarus needs an OS. I can cross compile to ARM but I need an OS on my ARM device (WinCE etc). I don't see the overlap though with the 32 bit PIC's there is room for an OS. I see the PIC world of C code controlling hardware without an OS and Lazarus as two separate worlds. Lazarus would need API's to interface to I2C SPI CAN bus etc. ---------------------------------------------------------------------- avra · 2012-08-03 09:44 Quote from: picstart on August 03, 2012, 04:03:33 amLazarus needs an OS. I can cross compile to ARM but I need an OS on my ARM device (WinCE etc). FPC ARM doesn't need an OS and you can still use Lazarus as an IDE (http://wiki.freepascal.org/TARGET_Embedded), however as I have already said peripherals need better support before serious use. There is also an AVR branch but it is highly experimental and not yet functional (http://wiki.freepascal.org/AVR). ---------------------------------------------------------------------- marcov · 2012-08-03 10:40 Quote from: KpjComp on August 02, 2012, 02:53:49 pm Well it never had an ARM chip, it had a RISC chip like I said.  ARM came later as a result of the RISC chip.  This is my take on it, Acorn were useless at selling into the business sector, and made the big mistake of concentrating on the educational sector.  And what makes your comment even odder, is from what I can gather PIC chips are now RISC anyway. PIC32 has MIPS10K (embedded Mips) core. But it is the minority PIC platform by far. ---------------------------------------------------------------------- marcov · 2012-08-03 10:56 Quote from: picstart on August 03, 2012, 04:03:33 amI have used PIC's for 20 years. I see the PIC as software controlled hardware with emphasis on the hardware peripherals. PIC's don't need an OS and are rarely multi-tasked. PIC's survive harsh environments ..inside washing machines etc. PIC's have extremely predictable timing since every instruction except goto takes  the same number of clock cycles and goto takes exactly twice as many. The de-facto language is C.  This does not go for the -E series of 16-bit PIC (pic24e, (ds)pic33e), these - also an extra cycle on a register -register stall (using the same register in the current instruction that you wrote in the last instruction) - extra cycle for read-write-modify instructions like bit-toggle. - interrupt latency varies due to pipelining, but can be set to the fixed worst case value (for a predictable latency) Still they are of course still more predictable, and make some of it up by having higher clocks (70MHz). Note that the peripheral hardware clock is double that, so e.g. PWMing can run on 140MHz (effective pin change frequency!) Afaik PIC32 has even more of these cases. QuoteLazarus needs an OS. I can cross compile to ARM but I need an OS on my ARM device (WinCE etc). Memory is even a greater problem. Like for embedded arms, something could be done about that with a cut down RTL. Even dspice have only 28kb unsegmented memory. (RAM).  Code is in separate flash. QuoteI don't see the overlap though with the 32 bit PIC's there is room for an OS. 128k?  In theory it is possible to up this with external RAM chips, but that usually eats too many precious pins and is slow.  Such memory is usually not very usable random-access. Quote I see the PIC world of C code controlling hardware without an OS and Lazarus as two separate worlds. Lazarus would need API's to interface to I2C SPI CAN bus etc. Not that much of a problem either. Microchips headers are autogenerated and could probably be autotranslated IF FPC would gain the relevant hardware specific instructions (and e.g. the bitlevel addressing) But the practical use would be low. (but that also goes for the most embedded ARM chips btw, like some of the older LPC ranges). If you do machine control, not instruction speed but actual reliable pin toggle speed is the core asset, together with instrumenting the on-chip periphery. Raw megahertzes are generally only needed for e.g. a webfrontend with a realtime generate graphs or displays with GUI stuff. For the actual job of the controller it is usually irrelevant. ---------------------------------------------------------------------- picstart · 2012-08-03 13:35 OK so you use Lazarus without an OS. I still don't see the advantage. With Lazarus I can develop an application with GUI on the PC ( without further work). Sure I have to be aware of the targets screen size etc.  After testing on the Windows PC a cross compile is performed to say an ARM device running Win CE..often it runs just as on the PC. Same with linux. Having an OS with a compatible subset of API's is the key to this process  Now for a PIC I use a separate IDE compile my C code then using ICSP  install the executable....I have a debugger with my PIC IDE ...I can stop make a fix to the C source recompile and via ICSP install the new code and be running again in less than a minute. Having access to the hardware at the register level in almost real time is key to this process as well as debugging with minimal or no impact on the PIC's execution timing due to the ICD the pic hardware provides. PIC plus C code and  Lazarus are two separate race horses that if combined would IMHO probably become a camel. ---------------------------------------------------------------------- KpjComp · 2012-08-03 16:06 QuoteI still don't see the advantage. Is there any reason you don't think JTAG gives you the same benefits of ICSP?. Also I believe it's possible to implement GDB with JTAG on ARM. So surely the benefits are using a more modern language, that you already have good knowledge of, rather than dropping into a less modern language like C. Reading Forums on PIC, one of the biggest complaints I can see is how Microchip haven't got with the times and updated there toolchain. ---------------------------------------------------------------------- picstart · 2012-08-03 18:43 ICSP on a PIC takes just two pins ( 4 if you include MCLR and GND). I use Jtag( many more pins ) mostly for FPGA's . It isn't apples to apples but a PIC using ICSP programs very very fast. It may be just habit but C in a PIC feels very close to the hardware almost as close as ASM.  Lazarus is a different animal floating high above the hardware above the BIOS and middleware ( it's what you want on a PC since you didn't solder the Motherboard yourself). Sure , you can use assembler in Lazarus and maybe get closer to the Motherboard but most often you need a driver. Compiling lazarus code from several years ago on the latest version isn't a safe bet. Often the prototype PIC board is hand soldered so there is comfort in C code being so close to the hardware, further the C code is uniquely adapted to the PIC hardware and its Harvard Architecture with special super efficient hardware extensions plus fusing, eeprom etc. C code from 20 years ago will very likely still compile and run in  a PIC. Anyway since the PIC C code works with 99% efficiency most don't think it needs replacing. Being multilingual both with human language and software is an advantage. C seems to enhance the electrical engineering part of the brain and feels natural as the next thing to do after the soldering iron cools. Design the circuit board ;solder the PIC and other components; write code to bring the PIC to life and test the board; next code in C the application then the interface to a PC port (usb  rs232).  Data is at a PC port so next use Lazarus to display it. ---------------------------------------------------------------------- BigChimp · 2012-08-03 18:55 I may be missing some things here (I'm even less of a hardware than a software guy) but this is a very interesting thread (nice to read about something completely different), so excuse me for jumping in and hope you guys can help me understand better. Aren't Pascal and C on about the same level regarding the low level things you can do with them? And yes, for lower level than Pascal you have inline assembler. I think you can perfectly program using only Object Pascal (no GUI/Lazarus forms etc) using Lazarus, in effect using Lazarus like a glorified text editor.... allowing you to even write your own operating system (IIRC, a hobby/amateur OS effort was TorOS). If your concern is that the assembler generated from FPC changes due to compiler changes etc... well... that's more of an FPC than a Lazarus problem, and presumably the solution is the same as that adopted by the C compiler writers: stabilize the compiler and use a certain version; only modify it if you take the generated assembler into account (i.e. pay much more attention to what assembly output you want compared to a desktop system). Finally, I'm struggling to see where you're going with your posts. Do you want to use FPC for low level hardware programming or not? If not, why go on about the disadvantages if you have chosen already. If you might (or do), why blame Lazarus for issues at the compiler level? I'm probably missing something fundamental here, and I'd love to know what. Thanks, BigChimp ---------------------------------------------------------------------- picstart · 2012-08-03 21:26 Big Chimp you are right it is just about preferences. Preferences are often a function of past experience. Pascal at one time was going to be universal but to run everywhere it needed to be compatible with all architectures. Architectures diverged into Von Neuman and Harvard RISC CISC and on and on. General Dynamics now Microchip saw a market in chips that could perform low level hardware functions like turn a washing machine off after x minutes. They protected the chips with substantial diodes on all pins so they didn't fail if abused. Assembler was the instruction set. As chips got more powerful assembler gave way to C albeit with embedded assembler. Microchip provided free IDE's and assemblers and compilers. There are hundreds of sizes for PIC chips..they are sized for the application. Recently due to cell phones having GUI's the ARM chip which if I'm right was a development from the need for mostly parallel FPGA logic to have advanced serial processing has gained volume. Chip lab's added hardware peripherals so ARM chips are found not only in consumer devices but also as MCU's. Volume in the cell phone market made consumer ARM chips competitive. Since the US  DoD promoted VHDL as a hardware definition language both it and a competing Verilog became the standard way of specifying CPU designs. An open RISC CPU design called ARM in VHDL and Verilog came about. An open IP brought more chip labs into the game. Now the possible and the practical take sides. The possible has a future bent the practical the past. I ran a business with hundreds of programmers it is rare to make money reinventing wheels. Being practical is very useful. The way to work with PIC's is established practice and also for those ARM's with a hardware peripherals  ( CAN I2C SPI ADC DAC etc). C is established for PIC's and hardware ARM's. Pascal was a distant "also ran". Sure anything that ultimately moves electrons can work but keeping focus on what Lazurus does best is important. Lazarus has replaced Delphi for PC's running linux and Windows and can provide excellent cross compiles to consumer handheld devices.  It could be argued that without Borland there would be no Lazarus. Borland created the need to replace Delphi. Lazarus has a non- corporate people power aura. This is a plus and a minus. The minus is without economic constraints it might grow too many branches and become the octopus that strangles itself. The plus is features are added without considering a business cost. Adding an ARM ( pun intended) feature to the octopus that takes it into the low level MCU arena looks like re-inventing wheels. Some will say it doesn't matter as long as it doesn't interfere. Entropy requires that everything tend to disorder the more complex the system the more the risk. That's why KISS has such a following. Far better to focus on a Lazarus that can continue to create Apps for the next consumer product and the next consumer OS. ---------------------------------------------------------------------- marcov · 2012-08-04 00:08 Quote from: picstart on August 03, 2012, 08:43:16 pm Often the prototype PIC board is hand soldered so there is comfort in C code being so close to the hardware, C is hardly closer to the hardware than the base level of Pascal, when similarly extended. If at all. I think Pascal would be the better suited language all things equal. Modula2 even would be better. But things are not equal, C is established, and any change is an investment you don't earn back. Quotefurther the C code is uniquely adapted to the PIC hardware and its Harvard Architecture with special super efficient hardware extensions plus fusing, eeprom etc. C code from 20 years ago will very likely still compile and run in  a PIC. Afaik PIC18's (needed for somewhat straight C) are more recent than 20 years, so 20 year old code will mostly likely use a software stack. And very few of it will be C. (most will be asm) Quote C seems to enhance the electrical engineering part of the brain and feels natural as the next thing to do after the soldering iron cools. Hmm, every time I make a type and type while (a=b) instead of while (a==b) I feel more like using the soldering iron on my brain. C is ugly, and one big ugly hack. However there is no need to glorify it, for the base (8 and 16-bit ranges like dspic) bits it is simply not worthwhile to replace it. Programs rarely used dynamic memory or are string intensive. For 32-bit CPUs it becomes different, but only if you have enough RAM. ---------------------------------------------------------------------- BigChimp · 2012-08-04 06:07 Thanks, guys. ---------------------------------------------------------------------- KpjComp · 2012-08-04 06:11 QuotePascal was a distant "also ran". You can see were this thread is going, maybe it's best leaving it at that.  Been there, done that, got the tea-shirt, and it's a bit boring now. ---------------------------------------------------------------------- jack616 · 2012-08-07 14:41 just an FYI Mikroe do a pascal compiler for PIC's so its not that odd an idea. Oh - and thanks to everyone who commented. ---------------------------------------------------------------------- boznz · 2012-09-07 01:17 Quote from: jack616 on August 07, 2012, 04:41:38 pmjust an FYI Mikroe do a pascal compiler for PIC's so its not that odd an idea. Oh - and thanks to everyone who commented. Yes Mikroe do a compiler for most Micro controllers AVR, 8051, PIC, ARM the only real problem is its US$250 to buy the licence to compile more than 2KB of code and you need to pay another US$250 for each chip-set (ie the 8 bit PIC compiler will not compile for PIC24 and the PIC24 compiler will not compile for PIC32) so it can get expensive, the libraries are also closed source :-( Apart from my `whinging` about $$$, I must say the Mikroes compilers, development systems and communities are pretty good and I've done several successful PIC8 projects with them over their boards over the years. I also like the Arduino development philosophy. Microchip and some ARM kits have embraced the design/philosophy with better hardware, (eg chipkit/Maple/Pinguino) but they are a long way from being up to the Arduino community level of support for newbies.  I feel a free-pascal version would be much easier for newbies than Wiring/C++ though this would be a major project to get off the ground (the AVR port of fpc will be fun to watch though) Simplifying the compiler target "ARM embedded" to be able to easily program the popular ARM development boards such as PIC32 pinguino ($US20) or ARM beaglebones ($US100) would be a great first step to moving a lot of electronics engineers back to pascal. Boz PS Version 1.0 of Lazarus is Awesome!