1/70
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
sleep instruction
command that puts the device into a low power mode until an interrupt is generated
inherent addressing
nop, return, sleep
no ooperand
absolute addressing
goto and call
allow program to jump to another location (address) in the program
literal (immediate) addressing
addlw, retlw
the destination is always the working register
file direct addressing
instructions that access the data store - addwf, movwf
outcome stored either in the working register or back in the file
bit addressing
bcf, bsf, btfsc, btfss
access the specified bit in a file register
file indirect addressing
internal register, the File Select Register is used to store the data
to trigger, specify the null address (0×00)
to change value stored inside, use the address 0×04
how to load a value into the program counter using PCL and PCLATH
bits <4:0> of the PCLATH will be bits <12:8> of the PC and bits <7:0> come from the PCL.
Write to PCLATH and then write to PCL
how to load a value into the program counter without using PCL
write value to PCLATH if needed
use call instruction, as it takes in a 13 bit literal and the PC is also 13 bits
move value into working register without triggering the flags
swapf 0×21, f followed by swapf 0×21, w as swapf does not affect any status flags
STATUS File 0×03 bits in order
IRP, RP1, PR0, /TO, /PD, Z, DC, C
STATUS IRP<7>
register bank select bit for file indirect addressing
STATUS RP1<6> and RP0<5>
register bank select bits - switch between banks 0, 1, 2 and 3
STATUS /TO<4>
time out
1 = after power-up, clrwdt or sleep instruction
0 = a WDT time out occured
STATUS /PD<3>
power down
1 = after power-up, or by the clrwdt instruction
0 = execution of the sleep instruction
STATUS DC<1>
digit carry / /borrow bit
1 = carry out between the nibbles occured
Little endian for (0×12345678)
leftmost address stores the two LSB (0×78)
Big endian for (0×12345678)
leftmost address stores the two MSB (0×12) - easier to read
stack structure
LIFO - last in first out
stack purpose
hold the subroutine return addresses
stack pointer is post-incremented and pre-decremented
lookup table structure
ORG 0×80
NAME: addwf PCL, f
retlw ?
polling
continously reading a signal
while ( this != that);
INTCON FIle 0×0B bits in order
GIE, PEIE, T0IE, INTE, RABIE, T0IF, INTF, RABIF
1 = enabled or interrupt occured
INTCON GIE<7>
general interrupt enable bit
1 = enable
INTCON PEIE<6>
peripheral interrupt enable bit
UNTCON T0IE<5>
TMR0 overflow interrupt enable bit
INTCON INTE<4>
RA2/INT pin external interrupt enable bit
INTCON RABIE<3>
PORTA/ PORTB change interrupt enable bit
INTCON T0IF<2>
TMR0 overflow interrupt flag bit
INTCON INTF<1>
RA2/INT pin external interrupt flag bit
INTCON RABIF<0>
PORTA/ PORTB change interrupt flab bit
how to enable the hardware interrupt
INTCONbits.GIE = 1;
INTCONbits.INTE = 1;
Program store/ program memory
persistent memory
holds the bit patters that define the operation of the program
RAM data memory/ data store
volatile memory
holds the data being processed by the program
can contain special function registers
EEPROM data memory
programmer readable/ writable persistent data memory
256 bytes of data accessed via special purpose registers EECON1, EECON2, EEDATA and EEADR
Persistent (non-volatile) memory
type of computer memory that can retain stored information even after power is removed
EEPROM and the program store
volatile memory
computer memory that requires power to maintain the stored information
RAM (data store - the file registers)
Configure all of PORT C pins to be digital inputs
set ANSEL and ANSELH to 0 to make them digital
set TRISC to 1 to make them inputs
how would you write a program to divide an 8 bit number by another 8 bit number
subtract the divisor from the dividend repeatedly until a carry (/borrow) is generated and then go back one iteration to get the final solution
program directive
are used to configure various options in relation to the operation of the device, for things such as code protection, enabling watchdog timer and oscillator setup
gives instructions to the assembler on how the program will be assembled or organised
assembly language instruction
line of code that is converted into executable machine code and executed by the CPU
two methods of including assembly language instructions in a C program
either the asm() for a single line of code or #asm to #endasm for multiple lines of code
for a variable to be shared between C and Assembly
ensure both variable definitions refer to the same location in the memory and are accessed using the same symbol name
stack pointer
3 bit register tied to the stack which points to the next available register in the stack
purpose of the TMR0 register
Timer0 module register that can count clock cycles (timer mode) or count external events (counter mode)
set up using the T0IF and T0IE bits in the INTCON register
purpose of the PCL register
stores the lower bytes of the program counter
purpose of the STATUS register
used to store flags that reflect the current state of the CPU and the results of operations
purpose of the FSR register
file select register is used to store the address of the data in file indirect addressing (file 0×04)
purpose of the EEADR register
used to store the address of the EEPROM data memory location that will be accessed in the read or write operation
file 0×10D
purpose of the EEDATA register
used to store the data that is currently being read/ written
file 0×10C
OPTION_REG INTEDG bit
used to select whether the interrupt will be generated on the rising or falling edge of the signal
PIE2 EEIE bit
Peripheral Interrupt Enable Register 2
EE Write Operation Interrupt Enable bit
EEPROM
electrically erasable programmable read only memory
PIR2 EEIF bit
Peripheral interrupt Request Register 2
EE Write Operation Interrupt Flag bit
advantages and disadvantages of using lookup tables
quicker and simpler than performing the calculations + lower CPU usage
takes up more memory space, only works for predefined values
char
8 bits (1 byte)
short
16 bits (2 bytes)
int
16 bits (2 bytes)
long
32 bits (4 bytes)
float
24 bits (3 bytes)
double
24 or 32 bits (3 or 4 bytes)
how to disable the oscillator and place the PIC in a low power standby mode
sleep instruction
special function register
used to control and monitor the internal hardware features of the device
INTCON, STATUS, TRISX, TMR0
reset vector
address 0×000 that the program jumps to on reset
interrupt vector
address 0×004 that the program jumps to whenever an interrupt is generated
Arithmetic and logic unit
carries out an arithmetic or logic operation as commanded by the mode code which is extracted from the instruction by the instruction decoder
Program store
each location has an address and holds one 14 bit long instruction
Data store
each file holds one byte of data. the file address is generated by the execute unit via the File Address Register and the contents of the addressed file are either read into the File Data Register or written to from it
File Address Register
when the CPU wants to access a file in the data store the address of the file goes into the FAR via the FA bus
File Data Register
bidirectional register which holds the contents of an addressed file of the CPU is executing a read cycle or that the CPU wants to send out to an existing memory location
why the goto instruction should never be used to call a subroutine
the goto instruction is unidirectional and it does not provide the program with a return address to be placed on the stack that the program can jump to when it finishes executing the subroutine