Академический Документы
Профессиональный Документы
Культура Документы
31/12/2014
Description
Arm Architecture
LGLite Intro & Interface
Simulator - Assembly
Simulator C, Pointers
LED Flash Assembly & C
Peripheral Clock PLL
Timer Interrupt Handling
External Interrupt - Counting
Day
9
10
11
12
13
14
15
16
Description
UART Serial Comm.
Pusle Width Modulation
Real Time Clock
Digital to Analog (DAC)
Analog to Digital (ADC)
Mux 7 segment
LCD Interfacing
I2C / SPI Protocol I/F
1. Software:
Fundamental assembly/C language programming skills.
2. Hardware: Computer architecture, functional hardware components
3. Applications: Skills to interface a variety of Int/external devices
The fundamental components of any CPU are ALU and Register banks.
Arithmetic/Logic Unit: performs basic operations on data elements. Registers are
used for fastest storage of temporary variables.
1.
2.
3.
4.
5.
31/12/2014
ARM is unlike previous microcontrollers in that all peripheral functions are not
built in. Its up to the manufacturer to add everything outside of the CPU functions
All peripheral functional units are memory mapped and not part of core.
31/12/2014
There is also a status register: CPSR, which contains a number of flags, which
latches and control the operation of the ARM7 core. The top four bits of the
CPSR contain the condition codes, which are set by the CPU. The condition
codes report the result status of a data processing operation. The ARM7 CPU is
capable of executing two instruction sets; the ARM instruction set which is 32 bits
wide and the THUMB instruction set, which is 16 bits wide and is reported by the
T flag. The ARM7 has seven different operating modes defined by the mode
bits.
When an exception occurs, the CPU will change operating mode and the PC be
forced to an exception vector. The vector table starts from address zero with the
reset vector and then has an exception vector every four bytes.
31/12/2014
One of the most interesting features of the ARM instruction set is that every
instruction may be conditionally executed. Every ARM instruction set has the top
four bits of the operand compared to the condition codes in the CPSR. If they do
not match then the instruction is not executed and passes through the pipeline as
a NOP (no operation).
The first four bits of an instruction are condition code and if its 1110(E) then this
instruction is not conditional and would be always executed. Bit 24 of the
Instruction is Link Bit and if this bit is set then R14 is loaded with the next
instruction address.
31/12/2014
Each instruction has a result register and two operands. The first operand must
be a register, but the second can be a register or an immediate value. ARM7
barrel shifter allows the second operand to be shifted by full 32- bits.
31/12/2014
31/12/2014
31/12/2014
31/12/2014
The System Control Block includes several system features and control registers
for a number of functions that are not related to specific peripheral devices.
The LPC2148 includes four External Interrupt Inputs as selectable pin functions.
The External Interrupt Inputs can optionally be used to wake up the processor
from Power-down mode.
There are two PLL modules in the LPC2141/2/4/6/8 microcontroller. The PLL0 is
used to generate the CCLK clock (system clock) while the PLL1 has to supply
the clock for the USB at the fixed rate of 48 MHz.
31/12/2014
The VPB Divider determines the relationship between the processor clock
(CCLK) and the clock used by peripheral devices (PCLK).
There is one bank of Flash memory with Memory Accelerator Module (MAM).
Each Data access that is not in the Data latch causes a Flash fetch of 4 words of
data, which are captured in the Data latch. This speeds up sequential Data
operations. After reset the MAM defaults to the disabled state.
31/12/2014
31/12/2014
31/12/2014
Connect Channel 1 thru 8 to the LCD data bus and Channel 9-15 to the LCD control bus.
Run the LGLite Pattern Generator at 1Khz sampling speed and monitor the display on
LCD.
31/12/2014
The Crossware Jaguar provides on-chip debug support. The debugging of the
target system requires a host computer running the Crossware software. Jaguar
converts the Remote Debug Protocol commands to the JTAG data needed to
access the ARM7TDMI-S core present on the target system for debugging.
31/12/2014
31/12/2014
31/12/2014
There are two PLL modules in the LPC2141/2/4/6/8 microcontroller. The PLL0 is
used to generate the CCLK clock (system clock) while the PLL1 has to supply
the clock for the USB at the fixed rate of 48 MHz. Structurally these two PLLs are
identical with exception of the PLL interrupt capabilities reserved only for the
PLL0
Following the completion of the desired interrupt service routine, clearing of the
interrupt flag on the peripheral level will propagate to corresponding bits in VIC
registers (VICRawIntr, VICFIQStatus and VICIRQStatus). Also, before the next
interrupt can be serviced, it is necessary that write is performed into the
VICVectAddr register before the return from interrupt is executed. This write will
clear the respective interrupt flag in the internal interrupt priority hardware.
31/12/2014
31/12/2014
LPC2148 UART
The LPC2148 features multiple serial interfaces including two UARTs (16C550),
with 16 byte FIFO, two Fast I2C-bus (400 kbit/s), SPI and SSP with buffering and
variable data length.
31/12/2014
The UART0 receiver block, U0RX, monitors RXD0, for valid input. The UART0
RX Shift Register (U0RSR) accepts bits via RXD0. The CPU passes it to the
UART0 RX Buffer Register FIFO to await access via the generic host interface.
The UART0 transmitter block, U0TX, accepts data written by the CPU and
buffers the data in the UART0 TX Holding Register FIFO (U0THR). The UART0
TX Shift Register (U0TSR) transmit the data via the serial output pin, TXD0.
The UART0 Baud Rate Generator block, U0BRG, generates the timing enables
used by the UART0 TX block. The U0BRG clock input source is the APB clock
(PCLK). The main clock is divided down per the divisor specified in the U0DLL
and U0DLM registers. Status information from the U0TX and U0RX is stored in
the U0LSR. Control information for the U0TX and U0RX is stored in the U0LCR.
31/12/2014
LPC2148 SPI
SPI is a full duplex serial interface with multiple masters and slaves being connected to a
given bus. Only the master device can control the clock line, SCK. During a data transfer
the master always sends 8 to 16 bits of data to the slave, and the slave always sends a
byte of data to the master.
31/12/2014
LPC2148 I2C-bus
There are two types of data transfers are possible on the I2C bus
1. Data transfer from a master transmitter to a slave receiver. The first byte
transmitted by the master is the slave address. Next follows a number of
data bytes. The slave returns an acknowledge bit after each received byte.
2. Data transfer from a slave transmitter to a master receiver. The first byte
transmitted by the master is slave address. The slave then returns an
acknowledge bit. Next follows the data bytes transmitted by the slave to
the master. The master returns an acknowledge bit after all received bytes
other than the last byte.
31/12/2014
LPC214x WDT
The purpose of the watchdog is to reset the microcontroller within a reasonable
amount of time if it enters an erroneous state. When enabled, the watchdog will
generate a system reset if the user program fails to feed (or reload) the watchdog
within a predetermined amount of time.
31/12/2014
31/12/2014
31/12/2014
C Primer
The C programming language was developed at Bell Labs during the early
1970's. Quite unpredictably it derived from a computer language named B and
from an earlier language BCPL.
As a programming language C program stores values in variables. Programs are
structured by defining functions. Program flow is controlled using loops, ifstatements and function calls. Related data can be stored together in arrays or
structure.
C is a so-called a compiled language. This means that once we write our C
program, we must run it through a C compiler to turn our program into an
executable that the CPU can run (execute). The C program is the humanreadable form, while the executable that comes out of the compiler is the
machine-readable and executable form (i.e. a list of CPU instructions).
A normal way of working is to compile our .c files into .obj files and link those,
together with other .obj files in (one or more) .lib files. After linking the file
extension in embedded systems the resulting executable could be a .hex file (an
actual flash memory image).
In practice the .c files are the source code, but the file startup.asm is an
assembler module provided by Crossware. As its name implies, the startup code
is located to run from the reset vector. It provides the exception vector table,
initializes the stack pointer, on-chip system peripherals and the on-chip RAM
before it jumps to the main function in your C code.
31/12/2014
Every C program must have a main; it defines which statements to execute upon
startup of the program. Functions define a series of statements to perform. A
function groups these statements and gives them a name (the function name).
One could say that functions are like black boxes that can perform some trick.
Calling the function performs the trick.
Once we have built some code and got it running on an LPC2148 device, it will at
some point be necessary to access the special function registers (SFR) in the
peripherals. As all the peripherals are memory mapped they can be accessed as
normal memory locations. Each SFR location can be accessed by hardwiring a
volatile pointer to its memory location as shown below.
The Crossware compiler comes with a set of include files (LPC2148.h), which
define all the SFRs in the LPC2148.
In addition to accessing the on-chip peripherals, your C code will have to service
interrupt requests. It is possible to convert a standard function into an ISR, as
shown below:
31/12/2014
C introduced data types integers, floating point, characters, and strings. These
types are known as standard types. C also provides means to build bigger types
from several smaller types, starting from these standard types.
The first major construct is called array; it is a series of objects of the same type.
The second major construct is a struct (i.e. a structure, also known as record); it
is a set of objects of multiple types. Structures in C allow us to group objects
(variables) of different type into one package.
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
31/12/2014
Trace the working of above function using new event as watch variable. Single step and
see how the variable changes state. This is very useful to understand working of I2C or
any state based protocols like USB or Ethernet. Monitor how do_event1 function changes
the state of the program. The state variable is maintained in new_event. I2C has to start
from a STOP state, Go to Start State, then to generate slave device Addr state, then
program the ADC control register to select one of the four ADC channel, this is the
Control state. Then go to stop state. The next state is to read the ADC conversion register.
Here again we go from Start, Addr, ADC with ack generation, ADC with nack generation
and then stop state.
31/12/2014
31/12/2014
Trace the working of above routines by connecting serial port P0.8 and P0.9 to external
serial interface and flag magic terminal at 9600 baud. Pin P0,4,P0.5,P0.6, and P0,7 to
25LC010A eeprom. The system boots up with a prompt > and echos back any terminal
write . The sequence of operation is as follows:
1. Type a character on Terminal. The UART1 captures the data in variable
serial_val.
2. The serial_val data is then written to 25LC010A using function dev_write()
3. The 25LC010A is then read back using dev_read() function.
4. The read back data is then echoed back to the terminal .
5. The # command erases the entire EEPROM.
31/12/2014
Use LGLite to capture SPI frames. Set the trigger word with SCK=1 and CS=0
LGLite Trigger word (XXX0 XXX1)
31/12/2014
31/12/2014
31/12/2014