PIC24 assembler templates - Page 1
Forum section: electronics / general

author: deephaven
author_rank: Frequent Contributor
timestamp: July 20, 2011, 01:03:15 pm
content: I'm after an initial template file for a PIC24 series device. There's lots of stuff to define with all those interrupt vectors etc and it would just take away some of the work and possible mistakes if this was already defined somewhere. I couldn't find anything on the Microchip website which only wants you to use C it seems. So do any templates exist?

author: Rufus
author_rank: Super Contributor
timestamp: July 20, 2011, 08:27:03 pm
content: I vaguely remember the same question being asked on the Microchip forums, can't remember if there was any useful response. Few people are mad enough to want to program in assembler a processor which has a decent (free) C compiler and architecture to use it.

author: Unknown
author_rank: Unknown
timestamp: July 20, 2011, 09:40:51 pm
content: I would expect the number of people programming a fairly large MCU entirely in assembly is quite low. Assembly is usually reserved for the small 6-8 pin devices with very limited amounts (if any) of RAM and ROM. It takes a lot of man years to fill up an average PIC24 in assembly. That might explain your troubles finding anything.

author: deephaven
author_rank: Frequent Contributor
timestamp: July 21, 2011, 09:03:03 am
content: I'm basically a hardware guy, however I have done quite a bit of programming for the PIC16 and PIC18 series always in assembler. I always think in 'hardware' terms and am uneasy with the vitualisation C gives you. I know you can have a look at what assembly the C has complied to, but then you just might as well written it in assembler in the first place.

author: johnmx
author_rank: Frequent Contributor
timestamp: July 21, 2011, 12:24:53 pm
content: Search Microchip’s website for ‘Code Examples’. Under the PIC24 examples, some are written in assembly. Modify and use any of those files as your template.http://www.microchip.com/TechDoc.aspx?type=CodeExamples

author: deephaven
author_rank: Frequent Contributor
timestamp: July 21, 2011, 01:29:50 pm
content: Quote from: johnmx on July 21, 2011, 12:24:53 pmAs far as I could see these are either for 16/18 series, anything higher is in C.As there didn't seem to be a shortcut I gave in and read the docs and have managed to create a framework which works.

author: Rufus
author_rank: Super Contributor
timestamp: July 21, 2011, 02:16:05 pm
content: Quote from: deephaven on July 21, 2011, 09:03:03 amI currently have a task to port and rewrite in C about 11 kloc of ugly assembler, written by someone who probably felt the same way. I reckon it is going to take a couple of months although half that is down to it being poorly documented and what it does being complicated. In the past I have ported 4 kloc of C doing similarly complicated low level hardware control to a new processor in a day and a half.Not like C is a high level language, many people (me included) consider it to be portable assembler.

author: hisense999
author_rank: Contributor
timestamp: July 21, 2011, 08:41:14 pm
content: Quote from: Rufus on July 21, 2011, 02:16:05 pmPerfect explaintation, this is why nobody use assembler today, and why C is so common, C is nothing more than friendly assembler - just assembler lovers not understand C enought, with understanding of pointers and references C code is translated into perfectly optimised assembler, yes assembler is must to know but only to get clue how to code in C to get optimised ASM code and I don't know any assembler guy which can win with modern C compilers

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 22, 2011, 12:48:53 am
content: Quote from: hisense999 on July 21, 2011, 08:41:14 pmekkk... wrong! it should be... "Perfect explaintation, this is why i dont use assembler today" i here means you, not me.