ED Unit-1
ED Unit-1
Example:
• Air conditioner
• Washing Machine
Related terms-
• Physical Computing: A computing system
which is aware of the environment, analyse
and present the output
• Embedded Systems
Comparing Embedded System and General Purpose Computing Systems
• The data memory can be seen at the top center of the diagram.
The data memory bus is 12 bits wide, capable of accessing
4Kbytes of data memory locations. As we shall see later, the data
memory consists of special function registers (SFR) and general
purpose registers, all organized in banks
• The bottom portion of the diagram shows the timers/counters,
capture/compare/PWM registers, USART, A/D converter, and EEPROM
data memory. The PIC18F452 consists of: 4 timers/counters 2
capture/compare/PWM modules 2 serial communication modules 8 10-
bit A/D converter channels 256 bytes EEPROM
• The oscillator circuit, located at the left side of the diagram, consists of:
Power-up timer Oscillator start-up timer Power-on reset Watchdog
timer Brown-out reset Low-voltage programming In-circuit debugger
PLL circuit Timing generation circuit
• The PLL circuit is new to the PIC18F series and provides the option of
multiplying up the oscillator frequency to speed up the overall operation.
The watchdog timer can be used to force a restart of the microcontroller
in the event of a program crash.
Architecture
• Consists of memory organization (RAM, ROM,
stack), CPU, timers, counters, ADC, DAC, serial
communication and I/O ports.
- Data Memory:
General Purpose Registers (GPR)
Special Function Register (SFR)
- STATUS registers
- PORT registers
- TRIS registers
- Data EEPROM
• Serial Communication- USART, SPI Protocol, I2C
Protocol
• I/O ports
Examples
• addwf f,d
Add contents of W with register f, if d=0 store result in W
else store in result f; e.g.: addwf 0x20,0
• clrf f
Contents of register f are cleared eg; clrf 0x30
• movwf f
Move data from W register to register f eg; movwf 0x04
• decfsz f,d conditional branching
Decrement register f, place result in f or w depending
on value of d; skip the next instruction if result is zero
NOP
e.g. decfsz 0x20,1
• decf f,d
Decrement f, place result depending on value of d
e.g. decf 0x30,1
Literal Operations
• Immediate addressing mode
Examples
• addlw k
Add literal k to register W,
e.g. addlw 0x05
• movlw k
move literal k into register W
e.g: movlw 0x21
Bit Oriented Operations
• Manipulate bits in control and status registers
Examples-
• bsf f,b
Set bit b (where b=0 to 7) in register f
eg: bsf 0x03, 5
• btfsc f,b
test bit b of register f, skip next instruction if bit is 0
eg. btfsc 0x03, 2
• Instructions bcf and bsf perform clear or set one bit anywhere in the memory
• retfie
Return from interrupt service routine and re-enable interrupts
• sleep
Go to standby mode, i.e. when no useful operation is performed
it is put to sleep
• clrwdt
Clear Watchdog timer
Example Code
• Decrement a 16 bit counter:
– upper byte of the counter COUNTH & lower byte
COUNTL
• Performing routine tasks. Many applications require the CPU to perform routine
work at precise times, such as checking the state of a peripheral device exactly
every millisecond. A timer interrupt scheduled with the required timing can
divert the CPU from normal program execution to accomplish the task at the
precise time required.
• To service peripheral devices quickly. Some applications may need to know when
a task, such as an A/D conversion, is completed. This can be accomplished by
continuously checking the completion flag of the A/D converter. A more elegant
solution would be to enable the A/D completion interrupt so the CPU is forced to
Interrupts in PIC
• Sources of interrupt are many
– INT pin interrupt from external source
– Port B change interrupt (RB7:RB4)
– Timer overflow interrupts
– USART interrupts
– A/D conversion interrupts
– LCD interrupt
– others
• The core interrupt sources are: External edge-
triggered interrupt on INT0, INT1, and INT2 pins.
PORTB pins change interrupts (any one of the
RB4–RB7 pins changing state)
Timer 0 overflow interrupt