0% found this document useful (0 votes)
20 views59 pages

Module 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views59 pages

Module 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ELG 4159

Integrated Control Systems


Module 1 – Microcontroller Programming
and Interfacing
By : Basim Hafidh Notes for
Prof. Wail Gueaieb
Outline

 Microcontrollers
 PIC16F917 Microcontrollers
 Memory organization and registers
 I/O Ports
 Programming PIC16F917
 Microcontroller’s Internal Oscillator
 Timers

2 © 2025 Basim Hafidh


Microcontrollers

 A microcontroller is a single Very-Large-Scale-Integration


chip that contains many digital circuits that perform
arithmetic, logic, communication and control functions.

 Microcontrollers are used in almost every electronic device


nowadays:
 dish washers, fax machines, TV sets, etc.

 Figure 1 shows a block diagram of a typical microcontroller.

 A typical microcontroller is composed of a CPU, a RAM, a


ROM, digital and analog I/O ports, a serial communication
interface, timers, and A/D and D/A converters.

3 © 2025 Basim Hafidh


Figure 1: Block diagram of a mechatronic system.

4 © 2025 Basim Hafidh


 ROM: is a non volatile memory and is used to store the program to
be executed. This program is referred to as the firmware.

 RAM: is a volatile memory and is used to store some values on


which the firmware depends.

 CPU: is the component that executes the firmware and controls all
the microcontroller’s other components.

 I/O ports: allows data to be transferred to and from the


microcontroller using external pins on the IC (Integrated Circuit).
This data can be, for instance, the state of an external switch, a
sensory data, a control voltage to be transferred to an actuator, etc.
An Analog I/O port is an I/O port carrying an analog signal, whereas
a digital I/O port is an I/O port carrying a digital (binary) signal.

© 2025 Basim Hafidh 5


 Serial Communication Interface: is a special I/O port that uses a
serial communication protocol. There are various serial
communication protocols including :
 SPI (serial peripheral interface),
 I2C (Inter-integrated circuit),
 USART (Universal Synchronous Asynchronous Receiver Transmitter).

 A/D Converter: is an IC that converts an external analog voltage


(from a sensor, for instance) to a digital value that can be processed
or stored by the microcontroller.

 D/A Converter: is an IC that allows the microcontroller to convert a


digital signal to an analog one (that can be transferred to an
actuator, for example).

 Timers: are usually used to help creating delays or ensure that


certain events occur at precise time intervals (e.g., reading sensory
data).
© 2025 Basim Hafidh 6
 There are many types of microcontrollers:
 Microchip’s PIC,
 Motorolla’s HCS12,
 Intel’s 8086,
 etc.
 In this course, the focus will be most on the Microchip PIC
microcontrollers due to its
 Wide acceptance in the industry
 Abundant information resources
 Versatile capabilities
 Ease of use
 Upward firmware compatibility and pin compatibility motors
,

 Relatively low cost sensons


 …….
E
 The board that is used in this course labs is the Mechatronics board
from Microchip, which carries PIC16F917.
 Microchip uses “PIC” to refer to its line of microcontrollers.
© 2025 Basim Hafidh 7
PIC16F917 Microcontrollers

 The microcontroller adopted in the course is PIC16F917.

 Most PIC16 microcontrollers have very similar architectures.

 The figure in [PC16F917 DataSheet, 2007, page 2] shows block


diagram of the PIC16F917.

 PIC16F917 is an 8-bit microcontroller that can hold up to 8Kx14


instructions (each instruction is composed of 14 bits).

 Its internal clock is typically driven at a speed of 8 MHz (software


controllable).

 Most instructions take 4 clock cycles to be executed.

© 2025 Basim Hafidh 8


a
hera
everypin
&

#
aximum
OTHEmeny

© 2025 Basim Hafidh 9


An =
malog

© 2025 Basim Hafidh 10


Program Memory Organization
E Flash

 PIC16F917 has an 8kx14 program memory (Flash) [PIC16F917 location

DataSheet, 2007, page 23].



OXOO
First instruction ORG :

= Goto initialize

ORG OXOS

I code
here
initialize
-

this
not use
will

=
we here
not sun start
- code
need
to

i every

© 2025 Basim Hafidh 11


Stimand
ERRO
use
than 01 we
can

either
27 Data Memory :
RAM

Organization
Bank
the

↑configuratoamsden ess

[Link]
programming-in-assembly

A
oh
O
o
0

Ag

5151FFh

new
=

S

20

1st p
e
xf -
>

© 2025 Basim Hafidh 12


-gromet
Data Memory Organization
 The data memory is partitioned into 4 banks.
512/4
 Each bank extends from address 00 to 7Fh (total of 128 bytes).
 Each bank contains General Purpose Registers (GPRs) and Special Function Registers
(SFRs).
 The first portion of each bank is composed of SFRs followed by GPRs.
 Some frequently used SFRs from one bank are mirrored in another bank for
code reduction and quicker access (no need to switch banks).
 The bank selection bits RP0 and RP1, which correspond to bits 5 and 6 of
the STATUS register, respectively. So to access bank 2, the programmer
must set RP1 = 1 and RP0 = 0.
 The data memory map of PIC16F917 is shown in [PIC16F917 DataSheet,
2007, page 26].

[Link]
© 2025 Basim Hafidh 13
(which assign Bitd
clean FirstBank
0x03 (example (
& ↑
11
BCF Status RPO
,

General Purpose Register File Bitcleagthe Gileregisten Status int


RPO

BCF Status RP1


,

 The register file of the PIC is made of 352 bytes (registers) in total.

 Each register can be accessed either directly through RP1, RP0, (to
specify the bank) and the op-code address field to specify the
address in that bank.
F File registen
=

accumulator
w= Work registen
 Example (Direct Addressing mode)
If RP1 and RP0 are set to 0, then
at the address of
the W and the content of thefile
ADDWF 0x7F => add the content
register
will add the content of the accumulator (working register) to the content
of the register in address 0x7F in bank 0 of the data memory and store
the result back in address 7Fh.

© 2025 Basim Hafidh 14


Indirect addressing mode
File select register =
FS &
-

 The other method of accessing a GPR or SFR is the indirect


addressing method. This method is based on a special register
called “INDF”.

 INDF is a logical (not physical) 9-bit register obtained by


concatenating a physical 8-bit File Select Register (FSR) and the
IRP bit (STATUS<7>). In this case, bit IRP and FSR<7> specify the
bank number and FSR<6:0> specify the address to be accessed in
that bank.

 Indirect addressing mode is commonly used when the programmer


-

prefer to store the address of the register to be accessed in a


register instead of explicitly specifying it in the program instruction.

 More details about indirect addressing mode are in [PIC16F917


DataSheet, 2007, page 41].
© 2025 Basim Hafidh 15
RAM
Status
Bitt in
C
FSR =

addressnk
Ba
this
of
BGF Status ,
I RP O

to
MOLW zoh Always have
use the work registen
FSR
MOU WE O When you want to
INL INDFE
access
to the file
egiste
a
~

INDF =
indirect file register
painten

to FSR is called
INDF
The register assigned
litend to work register
we

© 2025 Basim Hafidh 16


adness =
Bit 7 Bitz
register
Band
FSR =

[Link]
© 2025 Basim Hafidh 17
 Example (Clearing registers in addresses 20h to 2Fh of
Bank 0)

BCF STATUS,IRP ; Select Bank 0 (together


; with FSR<7>)
MOVLW 20h ;initialize pointer
MOVWF FSR ;to RAM
NEXT CLRF INDF ;clear INDF register
INCF FSR ;inc pointer
BTFSS FSR,4 ;all done?

C
GOTO NEXT ;no clear next
CONTINUE ;yes continue
BTFS
test =

Bit
instruction
check if it's zenoifyes goto next if 1 ship next

© 2025 Basim Hafidh 18


Special function registers (SFRs)

 SFRs are special purpose registers used by the CPU and peripheral
functions to control the desired operation of the microcontroller.

 There are two types of SFRs:


 Core SFRs are SFRs associated to the "Core" functions of the microcontroller.
 Peripheral SFRs are SFRs associated to the operation of the peripheral features
(LCD, I/O ports, A/D conversion, etc.)

 More details about the core SFRs can be found in [PIC16F917


DataSheet, 2007, pages 24–39].

© 2025 Basim Hafidh 19


I/O Ports

© 2025 Basim Hafidh 20


I/O Ports

 PIC16F917 has five 8-bit I/O ports:


 PORTA, PORTB, PORTC, PORTD and PORTE. Only bits 0 to 2 are
implemented in PORTE though.

 Every bit of an I/O port corresponds to an I/O pin on the PIC.


Example
PORTA<2> corresponds to pin RA2. See [PIC16F917 DataSheet,
2007, page 16].

 A TRIS register is associated to each port to configure it as an input


or output port. 1 intput
=

 TRISA for PORTA, TRISB for PORTB, etc. O = autput

 Setting a certain bit in a TRIS register to 1 (or 0) makes the


corresponding bit in the I/O port associated to that TRIS register an
input (or output) bit.
© 2025 Basim Hafidh 21
O 1 2 S

Analog select registen

© 2025 Basim Hafidh 22


[Link]
© 2025 Basim Hafidh 23
Example:

 Setting TRISA<5> to 1,
 configures PORTA<5> as an input bit.

 Setting TRISA<4> to 0,
 configures PORTA<4> as an output bit.

© 2025 Basim Hafidh 24


Analog Inputs
int put
Ifthey are
configure as

can
work as digital
intput = digital/andog
only
output = digital

>
-

can be digital
on andog

ANSEL Register

© 2025 Basim Hafidh 25


Analog Inputs

 In PIC16F917 all output pins have to be digital.

 All input pins, however, have to be digital but eight.


 In case RA5 (PORTA<5>), RA<3:0> (PORTA<3:0>), or RE<2:0>
(PORTE<2:0>), are configured as input pins, they can either be
configured as digital or analog input pins.
 This is configured through register ANSEL: 0 for digital and 1 for analog.

 More details about I/O ports are on [PIC16F917 DataSheet, 2007,


page 43]

© 2025 Basim Hafidh 26


Example 5 boat A

3
ponte
 Setting RA5 as an analog input pin. Iwe wanted to


use a intput pin as

digital no need
registen
;Select Bank 1 to set the digital
BSF STATUS,RP0 ; or BANKSEL TRISA
BCF STATUS,RP1
BSF TRISA,TRISA5 ; input (set to 1 = intput)

BSF ANSEL,ANS4 ; analog input (setANSY =


1 = analogist put
(RAS is multiplexed by ANS4) see page 25

 Setting RE1 as a digital output pin.

BCF TRISE,TRISE1 ; output


BCF ANSEL,ANS6 ; digital

© 2025 Basim Hafidh 27


Programming PIC16F917

 PIC16F917 will be programmed using assembly language.

 The instruction set used is detailed in Section 17 [PIC16F917


DataSheet, 2007, page 241].

 Table 17.2 [PIC16F917 DataSheet, 2007, page 242] summarizes


the instruction set.

 There are three main instruction categories:


 Byte-oriented instructions.
 Bit-oriented instructions.
 Literal and Control instructions.

© 2025 Basim Hafidh 28


Adduf 22 ,
0

add the content at the fileregister


1. Byte Oriented Instructionsadness at 22 + the contentof
accumulon

=> stone into the accumulation

 Byte oriented instructions operate on bytes (not bits), and involve


File registers and the accumulator W. where the result stone is

&

 Syntax: Instruction_symbol F , d or
Instruction_symbol F
 F represents the address of the file register to be used. The value of F
ranges from 0x00 to 0x7F.
 d is the destination designator which specifies where the result of the
operation is to be placed
d = 0 ⇒ the result is placed in W
d = 1 ⇒ the result is placed in the File register F.
The default value of d is 1.

 Examples
© 2025 Basim Hafidh 29
1. Byte Oriented Instructions halfcanny bit =
c =

DC canny
:
canny
bit
bit from 3 to Y

2 = Zeno
Instruction
Cycle (not neces

I
need any destin
,
cleanfile registen don't ,

clean accumulator

lifyau usea launten Jonex)

check not
(if we want to
if file on

MH2, do nothing)
(0 Sys
.
if we use8

&

© 2025 Basim Hafidh 30


2. Bit Oriented Instructions

 Bit oriented instructions operate on one-bit of the register rather than


the whole register.

 Syntax: Instruction_symbol F , b
 F represents the address of the file register to be used.
 b represents the bit number to operate on, ranging from 0 (LSB) to 7
(MSB)

© 2025 Basim Hafidh 31


2. Bit Oriented Instructions

Examples

[label] BSF REG,7

LAB_01 BTFSC REG,1 ; Test bit 1 of REG


LAB_02 .... ; execute this line if bit = 1
LAB_03 .... ; Jump here if bit = 0

© 2025 Basim Hafidh 32


3. Literal and Control Instructions

 Literal and Control Instructions involve the use of literals (constants


or labels). labels meanaddress

 Syntax: Instruction_symbol k or
Instruction_symbol
 k represents the literal (either a constant value or a label)

© 2025 Basim Hafidh 33


3. Literal and Control Instructions

(k)
= result in the accumulator

X will not usethis

X will not use this

© 2025 Basim Hafidh 34


Remarks about Microchip’s assembler

 By default, Microchip’s assembler assumes that numbers are


presented in a hexadecimal format unless otherwise specified. For
instance, the following instructions are equivalent:
MOVLW 12 ≡ MOVLW 12h ≡ MOVLW 0x12 ≡ MOVLW d‘18’ ≡
MOVLW b‘00010010’
T
decimal number
binary
 Instruction symbols (e.g., MOVWF, INCF) are case-insensitive,
-
whereas labels are case-sensitive.

© 2025 Basim Hafidh 35


(B
speedFrequence
Microcontroller’s Internal Oscillator

timen is a counter
werse timen
=>
to
generate delay

Y XY oo 0 0
© 2025 Basim Hafidh 36
Microcontroller’s Internal Oscillator

 Microcontrollers, in general, can be driven through an internal or


external oscillator (clock), which determines the execution speed of
the firmware.
 The internal oscillator of the PIC16F917 is controlled by the SFR
“OSCCON” (Oscillator Control Register).
 The internal oscillator frequency ranges from 31 KHz up to 8 MHz
depending on the values of OSCCON<6:4>.
 More details about the OSCCON SFR is on [PIC16F917 DataSheet,
2007, page 87].

 Example
Setting bits 6,5,4, of OSCCON to 1,0,1, respectively, sets the internal
oscillation to 2 MHz.

© 2025 Basim Hafidh 37


Timers

 The PIC16F917 comes with two 8-bit timers:


 Timer0 and Timer2, which count from zero to 255 (= 28 - 1).
and one 16-bit timer:
 Timer1, which counts from zero to 216 - 1.

initialize value -

the timen
of

© 2025 Basim Hafidh 38


TMR0 - The 8-bit timer
 The SFR associated with Timer0 is called TMR0.
 When the PIC’s internal oscillator is used as the clock source for the timer, it
will have the following configuration:
instruction speed
&

Prescolen is used for kigdelays


will be set when
TOIF timen
: Ointput flag
rolls from FF to
thecounten

1 (FOIF)
initialize counter Flagchange from O to
Delay >

Figure 2: Configuration of functionality of Timer0. The timing diagram in the middle assumes that
Prescaler = 2 and the initial value ©in2025
TMR0 is 0xAB.
Basim Hafidh 39
 Fosc is the PIC’s main oscillator’s frequency.

 TMR0 gets incremented automatically after each falling edge of the clock it
is connected to, regardless of what the firmware (CPU) is doing.

 When TMR0 reaches 0xFF it rolls back to 0x00 at the next incremental tick.

 The T0IF bit (which is INTCON<2>) is automatically set to 1 when TMR0


rolls over from 0xFF (255) to 0x00.

 The prescaler controls the frequency at which TMR0 is incremented.

 The value of the prescaler is determined by bits PS2, PS1, and PS0 of
OPTION_REG, which correspond to OPTION_REG<2:0>. presalen formula
 The prescaler possible values are described as follows: 24 x2
+ 1
=
2n

© 2025 Basim Hafidh 40


8

1 O O O O *
Y Y
41
always © 2025 Basim Hafidh -

presalen
Example I

grequency is MH2/Example
I
8

Configure the internal oscillator to 8MHz, timer0 to 128 Prescaler.


Initialize the timer to zero, and check out the T0IF.
; select Bank 1 ~ if
yaudon't
>

know whica with 'negenpage so

BSF STATUS, RP0 or*BANKSEL OSCCON


BCF STATUS, RP1
; Set internal oscillator freq
MOVLW b’01110000’ ; 8MHz
MOVWF OSCCON
; Set TMR0 Parameters
MOVLW b’1 0 0 0 0 110’ ; Port B pullup disabled;
;TMR0 prescaler 1:128
MOVWF OPTION_REG

© 2025 Basim Hafidh 42


3
This is already given ,
; turn off Comparators
MOVLW 0x07
MOVWF COMCON0
Bank !
in Bank Owe need to go to
BCF STATUS,RP0 ; Bank 0 ,
we were

CLRF TMR0 ; clear TMR0 and


BCF INTCON, T0IF ; TMR0 overflow flag
NEXT BTFSS INTCON,T0IF ; TMR0 overflow?
ifset
1 C GOTO NEXT if 0
BCF INTCON, T0IF
;
;
no
yes, clear the flag
timenOis always active always working
,

© 2025 Basim Hafidh 43


Timer0 Calculations
 The behavior of Timer 0 is controlled by 3 parameters (i.e., 3 degrees of
freedom): Fosc , the timer’s prescaler and initial value. These parameters
are determined as follows:
1. Determine a suitable combination of Fosc and prescaler, such that

is maximized while keeping its TMR_Max_Ticks = 28 = 256.

2. Calculate the timer’s initial value (to be stored in TMR0) using (1).

Remarks
 If the calculated initial value turns out to be non-integer, it is an indication
that the exact target delay cannot be generated.
 In that case, the best one can do is to generate a delay as close as possible to
the target delay by rounding the timer’s initial value to the nearest integer.
 This leads to a timing error (i.e., difference between the generated and the target
delay). © 2025 Basim Hafidh 44
 The time (Delay) taken to roll back to 0x00 is

(1)

TMR_Max_Ticks ≡ max possible number of ticks = 28 = 256


TMR_Initial_Value ≡ Initial value in TMR0

© 2025 Basim Hafidh 45


Example

Fpi Fpo

Assume that the PIC main oscillator is running at 8 MHz


1. Can you create a delay of 0.7 µsec?
2. With this configuration (Fosc = 8 MHz, prescaler = 2) is it possible
to generate a delay of 3 µsec?
3. Is it possible to generate a delay of 4.7 µsec?
What’s the initial value to set TMR0 to?
What’s the resultant error in the generated delay?

© 2025 Basim Hafidh 46


1. Can you create a delay of 0.7µsec?

Fosc is given 8 MHz


Fpi : Freq. of the prescaler’s input pulses
Fpi = Fosc /4 =2 MHz ⇒Tpi = 0.5 µsec

Fpo : Frequency of the Prescaler’s o/p pulses


Fpo = Fpi / prescaler value
Tpo = Tpi x prescaler value

The smallest possible value of the Tpo is when the prescaler value is
chosen as (2).
⇒ Smallest possible Tpo in this case is 2 x Tpi = 2 x 0.5 = 1 µsec

Thus, it takes the timer 1 µsec to increment.

Therefore, with Fos = 8 MHz it is not possible to generate a delay less


than 1 µsec

© 2025 Basim Hafidh 47


2. With this configuration (Fosc = 8 MHz, prescaler = 2) is it possible to
generate a delay of 3µsec?

3 µsec is a perfect multiple of Tpo = 1 µsec;


3 µsec = 3 x Tpo

This means that it takes TMR0 exactly 3 transitions to “fill” 3 µsec.

The idea here is to force the last transition to correspond to: “0xFF →
0x00” so that the flag T0IF is set to 1 as soon as the target time (3 µsec) is
elapsed.

Therefore, TMR0 must be initialized to 0xFD

1 2 3
0xFD → 0xFE → 0xFF → 0x00 (T0IF =1) → ………..
© 2025 Basim Hafidh 48
3. Is it possible to generate a delay of 4.7µsec? What’s the initial value
to set TMR0 to? What’s the resultant error in the generated delay?

(4 x Tpo = 4 x 1 µsec) < 4.7 µsec < (5 x Tpo = 5 x 1 µsec = 5 µsec)

The closest delay possible to 4.7 µsec is 5 µsec


⇒ and error of 0.3 µsec

It takes 5 counts of TMR0 to cause a delay of 5 µsec

Thus, TMR0 must be initialized to 0xFB so that the last timer transition is
“0xFF → 0x00”

1 2 3 4 5
TMR0: 0xFB → 0xFC → 0xFD → 0xFE → 0xFF → 0x00 (T0IF =1) → →

© 2025 Basim Hafidh 49


Remarks

 Timer0 is always enabled in PIC16F917. It cannot be disabled.

 To set Timer 0 prescaler value, it is recommended (for the sake of


this course) to initialize OPTION_REG to 10000xxx, where xxx
depends on the prescaler value of your choice.

 It is also recommended (for the sake of this course) to turn OFF the
comparators by initializing SFR CMCON0 to 0x07. Comparators will
not be used in the course, but they are enabled by default in
PIC16F917.

 More details on TMR0 are on Section 5 of [PIC16F917 DataSheet,


2007, pages 99].

© 2025 Basim Hafidh 50


Case Study

 Write a program so that every time the tactile switch SW2 on the
mechatronics board is pressed, LED (D0) is toggled (on/off).
 SW2 (input) can be connected to pin RA0 of the PIC, which will have to
be configured as a digital input pin since the signal connected to SW2 is
digital
 LED D0 (output) can then be connected to pin RD7 of the PIC, which
will have to be configured as a digital output pin.
Vcc

RA0
RD7
SW2

PIC16F917
D0

© 2025 Basim Hafidh 51


[Link]

© 2025 Basim Hafidh 52


16 ms
(Not Pressed)
main DS2 DS2 DS2  main
5v
0v
DS1 DS1 DS1
(Pressed)

While not While pressed While not pressed and


pressed stay here time <16 ms stay here

If pressed, If released,
toggle LED start timer0

Not Pressed Pressed Not Pressed


(Main) (DS1) (DS2)

If pressed
within 16 ms
16 ms elapsed while
switch not pressed

© 2025 Basim Hafidh 53


#include <[Link]> ;a file containing all the SFR
;addresses of pic16f917
#define SW2 PORTA,0
#define LED PORTD,7
ORG 0X00
GOTO initialize
ORG 0X05
initialize
BSF STATUS,RPO ;bank 1
BCF STATUS,RP1
BCF TRISD,7 ;RD7 is an output
BSF TRISA,0 ;RA0 is an input
;set internal oscillator freq
MOVLW b’01110000’
MOVWF OSCCON

© 2025 Basim Hafidh 54


; Program 1 (No debouncing – ideal pushbutton))
BCF STATUS, RP0 ;bank 0
BCF LED ;clear the LED
main
BTFSC SW2 ;loop here until sw2 is pressed
GOTO main
MOVLW b’1000 0000’;exclusive oring port D with 0x80
XORWF PORTD ;will effectively toggle RD7 on and off
GOTO main
END
main main
5v
0v

Ideal pushbutton

© 2025 Basim Hafidh 55


; Program 2 (debouncing)
; set timre0 parameters
MOVLW b’10000 110’;TMR0 prescaler 1:128
MOVWF OPTION-REG
;turn off comparators
MOVLW 0X07
MOVWF COMCON0 ;turn off comparators
;turn off analog
CLRF ANSEL
;clear the LED
BCF STATUS ,RP0 ;bank0
BCF LED
main
BTFSC SW2 ;loop here until sw2 is pressed
GOTO main
MOVLW b’1000 0000’;exclusive oring port D with 0x80
XORWF PORTD,f ;will effectively toggle RD7 on and off
© 2025 Basim Hafidh 56
DS1 BTFSS SW2 ;wait here until SW2 is released
GOTO DS1
CLRF TMR0 ;once released clear tmr0 and T0IF flag
BCF INTCON,T0IF ; in preparation to time 16 msec
DS2 ;state 2 makes sure that SW2 is not pressed for 16 ms
;before returning to look for the next time SW2 is
;pressed. If SW2 is again in this state then return to
;DS1, else continue to count down 16 msec
BTFSS SW2
GOTO DS1
BTFSS INTCON, T0IF
GOTO DS2
GOTO main
END

© 2025 Basim Hafidh 57


HW for Problem Set 1

1. In problems 1 and 2, rewrite the code using FSR register as a


counter as well.
2. In problem 3, rewrite the code by assuming the array is located in
bank 3, and use FSR register as a counter as well.

© 2025 Basim Hafidh 58


References

[PIC16F917 DataSheet, 2007] PIC16F917 DataSheet (2007).


PIC16F913/914/916/917/946 Data Sheet.
Microchip Technology Inc., f edition.
[Link]

© 2025 Basim Hafidh 59

You might also like