I've been battling a little PIC for a couple weeks in my spare time...
Why did I chose PIC over AVR? Now the question buffles me again. Truth be told, AVRs don't seem to frequent multiple serial ports on a small chip. The price of simplest PIC with 2 UARTS was twice less that of simplest AVR with 2 UARTS. That was basically why.
However for the 2 USD I won having made the choice I seem to have to pay back in spades.
Why could I think of AVR? The most important is the compiler. If the wise GNU people already spent almost 23 years writing it, why not use it? Indeed AVR is the right way. I thought a proper recommended compiler for PICs, the C18 could not be so bad. Not so.
A quick example. I want to play with 2 serial ports, in C18 I have to use separate functions DataRdy1USART and DataRdy2USART to see if I'm getting something on the serial lines. Worse then, if I only had 1 serial port on a pic I'd have to use a third function, DataRdyUSART. Let alone the slightly abbreviated, two-thirds-camel-case-one-third-all-caps names, if I were to check the error state, I have to read from the uart, and then the crown jewel -- say I wanted to output a string of text, C18 library provides a function for that -- puts1USART (notice yet another capitalization scheme), which outputs a null-terminated string... including the null character!
Then let's consider a function DisablePullups. A programmer would think a bit and start digging what its arguments might mean - which port? what pins? Alas! it only works on PORTB and on all pins at once.
Someone said PICs have best documentation. Not quite so. I've encountered several mistakes and in the first PIC datasheet I ever worked with and it seems that trying to contact the documentation team is not as easy as it was made out to be. Through the powers of google, find in files, find in pdf, google again and the hordes of others who have trod this path before me I was able to resolve all the issues I had so far, but it took much precious time.
I'm afraid these gotchas that got me are just the beginning, meanwhile the battle rages on...
Next time I start with AVR and see where that leads me!
P.S. PICs have many advatanges, easier access to multiple serial ports is just one of these. If you wanted CAN or Ethernet on cheap, AVR got just 1 practical model, PIC got many, and I bet these are just the beginning too.
Thursday, 28 January 2010
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment