End Sem Exam
End Sem Exam
End Sem Exam
Timer0:
- Can be configured as an 8-bit or 16-bit timer or counter.
- Clock source options: internal instruction cycle clock or T0CKI signal.
- Clock signal can be divided by a prescaler before connecting to Timer0's clock input.
- T0CON register controls Timer0's operation.
- Operates as a timer when the clock source is the instruction cycle clock.
- Operates as a counter when the clock source is the T0CKI pin.
Timer1:
- 16-bit timer/counter depending on the clock source.
- Interrupt request possible when Timer1 rolls over from 0xFFFF to 0x0000.
- Timer1 can be reset when the CCP module is configured to compare mode.
- T1CON register controls Timer1's operation.
- Timer1 can use the oscillator connected to the T1OSO and T1OSI pins.
- Intended for a 32 KHz crystal.
- Can be used for time delays and measuring unknown signal frequencies.
Timer2:
- Consists of 8-bit timer TMR2 and 8-bit period register PR2.
- TMR2 counts up and compares with PR2 in every clock cycle.
- EQ signal resets TMR2 when TMR2 equals PR2.
- Postscaler generates the TMR2 interrupt.
- TMR2 output is fed to the synchronous serial port module.
- T2CON register controls Timer2's operation.
Timer3:
- Consists of two 8-bit registers, TMR2H and TMR2L.
- Clock source options: internal (instruction cycle clock) or external signal.
- Reading TMR3L loads the high byte of Timer3 into the TMR3H register.
CCP (Capture/Compare/PWM):
- CCP module is a peripheral used for timing and controlling events.
- It has three modes of operation: Capture, Compare, and PWM.
- Capture mode: Captures the time of an event by measuring the
arrival time of a signal at the CCP pin.
- Compare mode: Generates an output when Timer 1 reaches a
specified value set in CCPR1 register.
- PWM (Pulse Width Modulation) mode: Provides a PWM output
with 10-bit resolution for controlling the duty cycle.
- Capture Mode:
- Used for pulse time measurement.
- Captures the value of Timer 1 when a signal at the CCP pin goes
high or low.
- Compare Mode:
- Generates an output when Timer 1 matches a value set in the
CCPR1 register.
- Special event trigger mode can be used to start the ADC (Analog-
to-Digital Converter).
- PWM Mode:
- Provides a PWM output with 10-bit resolution.
- No software overhead once started, operates automatically.
- Uses Timer 2 to define its operation.
- Timer 2 period register sets the frequency of the PWM signal
Interrupts Handling:
- Enable Bit (IE): Used to enable/disable the interrupt. Set to '1' to enable the interrupt.
- Flag Bit (IF): Automatically set by the related hardware when the interrupt condition occurs.
Indicates that the interrupt has occurred.
- Priority Bit: Determines the priority of the interrupt source (not used in this explanation).
- Interrupt Vector:
- Address where the CPU jumps when an interrupt occurs. In PIC18, this address is 0008 (hex).
- The ISR determines the source of the interrupt based on the flag bit.
- Contains the IPEN (Interrupt Priority Enable) bit and other bits related to device reset.
- Contains GIEH (Global Interrupt Enable High) and GEIL (Global Interrupt Enable Low) bits.
- Enables interrupts and stores enable, priority, and flag bits for various interrupt sources.
- Contains interrupt flags for peripheral interrupt sources such as ADC, UART, CCP, USB, and timers.
- Contains enable bits for peripheral interrupt sources. Setting a bit enables the associated
interrupt source.
- Used to set the priority of individual interrupt sources if IPEN bit is set.
- Setting the IPR bit makes the source high priority, while clearing it makes it low priority.
- Flag bits: Set or clear the interrupt flag for the source. It is important to clear the flag before
enabling interrupts for that source
Write an ARM assembly/ C program to use on-chip UART for receiving
data with a baud rate of 9600 and store in character array or memory.
#include<LPC214X.H>
int i=0;
void main()
{char a[];
communication
U0DLM=0X00;
while(1)
for(i=0;i<100;i++) {
a[i]=U0RBR;
i=i+1; }}}
Write a PIC18F assembly language program to read data from ROM location address 500H to RAM
location 0x40 of an access bank
.
Thumb mode improves code density by using 16-bit instructions instead of 32-bit instructions in
the ARM mode. This allows more instructions to fit in a given memory space, resulting in reduced
code size and potentially better overall system performance.
To switch between ARM and Thumb modes, the LPC2148 microcontroller provides two instructions:
`BX` and `BLX`
The `BX` instruction is used to branch to a new address and simultaneously switch between ARM
and Thumb modes. Here's how it work
assembly
BX ThumbAddress
Replace `ThumbAddress` with the address of the desired Thumb instruction. The address must
have the least significant bit set to 1 to indicate Thumb mode.
assembly
BX ARMAddress
Replace `ARMAddress` with the address of the desired ARM instruction. The address does not
need to have any specific bit set since it indicates ARM mode by default.
The `BLX` instruction is similar to `BX`, but it also saves the return address in the link register (`LR`)
for later use. It can be used for interworking between ARM and Thumb modes as well. Here's how to
use it:
assembly
BLX ThumbAddress
Replace `ThumbAddress` with the address of the desired Thumb instruction (with the least
significant bit set to 1)