What is a programmer?
In the world of embedded systems, a programmer can be a person who writes software for a microcontroller or a device for downloading programs onto a microcontroller.
Useful documents
- PIC24HJ32GP202/204 and PIC24HJ16GP304 data sheet
- PIC24HJ32GP302/304, PIC24HJ64GPX02/X04 and PIC24HJ128GPX02/X04 data sheet
- 16-bit MCU and DSC Programmer’s Reference Manual
- PIC24H Family Reference Manual
- MPLAB® XC16 Assembler, Linker and Utilities User’s Guide
Harvard architecture
Just the number
- Program memory (chip data sheet, pp. 25)
- 224 16-bit words 32 MB
- But ignoring the ”phantom“ byte, 223 24-bit words 24MB
- Data memory (chip data sheet, pp. 28)
- 216 8-bit words 64 kB
A little detail
- Program memory (chip data sheet, pp. 25)
- User memory
- address of interrupts and traps
- flash memory for program (a few thousand instructions)
- Configuration memory
- Device configuration
- DEVID — Device identification
- User memory
- Data memory (chip data sheet, pp. 28)
- SFR: Special Function Registers
- RAM
- PSV: Program Space Visibility
Special Function Registers are similar to the memory-mapped I/O of larger processors. Program Space Visibility is similar to virtual memory.
Registers
The Special Function Registers are similar to two types of registers found in larger computers.
- Processor registers — a small collection of memory, separate from addressable memory, used for arithmetic, flow control, and memory access operators
- Device registers —
The PIC processor also contains shadow registers (see the programmer view on page 19).
PIC SFR’s are described in great detail in the processor data sheet (starting at page 29).
- working registers
- stack pointer limit
- program counter
- status register
- port registers (page 105)
Assembling language programming
You can write the following on the PIC.
MOV X,W9 ADD W9,#4,W10 MOV W10,Y BRA NZ,FACT
But every one of the following instructions are illegal on the PIC processor used in class.
MOV X,Z ADD W7,#57,W3 MUL W9,#4,W10 BRA W3,NZ,FACT
More more thing about integers
On the PIC processor stores integers in 16 bits or 2 addressable
bytes.
If 2013
, also known as 0x7DD
,
is stored in two bytes starting at memory location
0xA00
; what is stored in
byte 0xA00
and what is stored in
byte 0xA01
.
In a little-endian computer, such as the PIC or Intel x86-64,
byte 0xA00
contains value 0xDD
and
byte 0xA01
contains value 0x07
.
It’s the other way around on a big-endian computer.
The Network byte order of the Internet Protocol is big-endian. Programmers writing low-level networking code have to call routines such as htons to avoid misunderstandings.