Вы находитесь на странице: 1из 52

The MICROPROCESSOR

PRINCIPLES AND
APPLICATIONS
Lab 7

Timer, USART

Cheng-Chien Su

Home Automation, Networking, and Entertainment Lab
Dept. of Computer Science and Information Engineering
National Cheng Kung University, TAIWAN
 Timer0 Introduction & Operation
Outline
 Timer1 Introduction & Operation
 C18 C Libraries of Timer
 USART Introduction & Operation
 C18 C Libraries of USART
 Lab
 Reference

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 2
 The Timer0 module incorporates the
Timer0
Introduction
following features:
 Software selectable operation as a timer
or counter in both 8-bit or 16-bit modes
 Readable and writable registers
 Dedicated 8-bit, software programmable
prescaler
 Selectable clock source (internal or
external)
 Edge select for external clock
 Interrupt-on-overflow

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 3
 The T0CON register controls all aspects of
Timer0 the modules operation, including the
Introduction prescale selection. It is both readable and
writable.
Block Diagram
 A simplified block diagram of the Timer0
module in 8-bit mode is shown in figure.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 4
Timer0
Introduction

T0CON Register

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 5
 An 8-bit counter is available as a
Timer0
Introduction
prescaler for the Timer0 module.
 Its value is set by the PSA and
Prescaler T0PS2:T0PS0 bits (T0CON<3:0>)
which determine the prescaler
assignment and prescale ratio.
 Clearing the PSA bit assigns the
prescaler to the Timer0 module.
 When it is assigned, prescale values
from 1:2 through 1:256 in power-of-2
increments are selectable.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 6
 Timer0 can operate as either a timer or a
Timer0 counter; the mode is selected with the T0CS
Operation bit (T0CON<5>).
 In Timer mode (T0CS = 0), the module
increments on every clock by default unless a
different prescaler value is selected.
 The user can work around this by writing an
adjusted value to the TMR0 register.
 The Counter mode is selected by setting the
T0CS bit (= 1). In this mode, Timer0
increments either on every rising or falling
edge of pin RA4/T0CKI.
 The incrementing edge is determined by the
Timer0 Source Edge Select bit, T0SE
(T0CON<4>); clearing this bit selects the
rising edge.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 7
 The TMR0 interrupt is generated when the
Timer0 TMR0 register overflows from FFh to 00h in
Operation 8-bit mode, or from FFFFh to 0000h in 16-bit
mode.
Interrupt
 This overflow sets the TMR0IF flag bit. The
interrupt can be masked by clearing the
TMR0IE bit (INTCON<5>).
 Before re-enabling the interrupt, the TMR0IF
bit must be cleared in software by the
Interrupt Service Routine.
 Since Timer0 is shut down in Sleep mode, the
TMR0 interrupt cannot awaken the processor
from Sleep.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 8
 The Timer1 timer/counter module
Timer1
Introduction
incorporates these features:
 Software selectable operation as a 16-bit
timer or counter
 Readable and writable 8-bit registers
(TMR1H and TMR1L)
 selectable clock source (internal or
external) with device clock or Timer1
oscillator internal options
 Interrupt-on-overflow
 Reset on CCP Special Event Trigger
 Device clock status flag (T1RUN)

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 9
Timer1
Introduction

Block Diagram

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 10
Timer1
Introduction

T1CON Register

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 11
 Timer Functions: the timer peripherals
C18 C Libraries
of Timerx
are supported with the following
functions:
Overall  CloseTimerx
 OpenTimerx
 ReadTimerx
 WriteTimerx

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 12
 OpenTimer0: Configure and enable timer0.
 Include: timers.h
C18 C Libraries  Prototype: void OpenTimer0( unsigned char config );
of Timer  Arguments: config
 Enable Timer0 Interrupt:
 TIMER_INT_ON Interrupt enabled
 TIMER_INT_OFF Interrupt disabled
OpenTimer0  Timer Width:
 T0_8BIT 8-bit mode
 T0_16BIT 16-bit mode
 Clock Source:
 T0_SOURCE_EXT External clock source (I/O pin)
 T0_SOURCE_INT Internal clock source (TOSC)
 External Clock Trigger (for T0_SOURCE_EXT):
 T0_EDGE_FALL External clock on falling edge
 T0_EDGE_RISE External clock on rising edge
 Prescale Value:
 T0_PS_1_1 1:1 prescale
 T0_PS_1_2 1:2 prescale

 T0_PS_1_256 1:256 prescale
 Remarks: This function configures timer0 according to the options
specified and then enables it.
 Code Example:
 OpenTimer0( TIMER_INT_OFF & T0_8BIT & T0_SOURCE_INT &
T0_PS_1_32 );

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 13
 OpenTimer1: Configure and enable timer1.
 Include: timers.h
 Prototype: void OpenTimer1( unsigned char config );
C18 C Libraries  Arguments: config
Enable Timer1 Interrupt:
of Timer 
 TIMER_INT_ON Interrupt enabled
 TIMER_INT_OFF Interrupt disabled
 Timer Width:
OpenTimer1  T1_8BIT_RW 8-bit mode
 T1_16BIT_RW 16-bit mode
 Clock Source:
 T1_SOURCE_EXT External clock source (I/O pin)
 T1_SOURCE_INT Internal clock source (TOSC)
 Prescaler:
 T1_PS_1_1 1:1 prescale
 T1_PS_1_2 1:2 prescale
 T1_PS_1_4 1:4 prescale
 T1_PS_1_8 1:8 prescale
 Oscillator Use:
 T1_OSC1EN_ON Enable Timer1 oscillator
 T1_OSC1EN_OFF Disable Timer1 oscillator
 Synchronize Clock Input:
 T1_SYNC_EXT_ON Sync external clock input
 T1_SYNC_EXT_OFF Dont sync external clock input
 Remarks: This function configures timer1 according to the options
specified and then enables it.
 Code Example:
 OpenTimer1( TIMER_INT_ON & T1_8BIT_RW & T1_SOURCE_EXT &
T1_PS_1_1 & T1_OSC1EN_OFF & T1_SYNC_EXT_OFF );

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 14
 WriteTimer0: Write a value into the
C18 C Libraries specified timer.
of Timer
 Include: timers.h
WriteTimer0  Prototype: void WriteTimer0( unsigned
int timer );
 Arguments: timer
 The value that will be loaded into the
specified timer.
 Remarks: These functions write a
value to the respective timer
register(s):TMR0L,TMR0H
 Code Example: WriteTimer0( 10000 );

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 15
 ReadTimer0: Read the value of the specified
C18 C Libraries timer.
of Timer  Include: timers.h
 Prototype: unsigned int ReadTimer0( void );
ReadTimer0  Remarks: These functions read the value of
the respective timer register(s):
TMR0L,TMR0H
 Return Value: The current value of the timer.
 Note: When using a timer in 8-bit mode that
may be configured in 16-bit mode (e.g.,
timer0), the upper byte is not ensured to be
zero. The user may wish to cast the result to
a char for correct results.
 Code Example:
unsigned int result;
result = (unsigned char) ReadTimer0();

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 16
 CloseTimer0: Disable the specified
C18 C Libraries
of Timer
timer.
 Include: timers.h
CloseTimer0
 Prototype: void CloseTimer0( void );
 Remarks: This function disables the
interrupt and the specified timer.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 17
#include <p18C4520.h>
#include <timers.h>
C18 C Libraries #include <stdlib.h>
void main( void ){
of Timer int result;
char str[7];
// configure timer0
Example OpenTimer0( TIMER_INT_OFF &
T0_SOURCE_INT &
T0_PS_1_32 );
TRISD = 0;
while( 1 ) {
while( ! PORTBbits.RB3 ); // wait for RB3 high
result = ReadTimer0(); // read timer

if( result > 0xc000 ) // exit loop if value


break; // is out of range
WriteTimer0( 0 ); // restart timer

PORTD = (unsinged char) result;


}
CloseTimer0(); // close modules
}

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 18
 The Enhanced Universal Synchronous
Asynchronous Receiver Transmitter (USART)
USART
module is one of the two serial I/O modules.
Introduction
 The USART can be configured
 A full-duplex asynchronous system, such as
personal computers, etc.
 A half-duplex, synchronous system, such as serial
EEPROMs, etc.
 The Enhanced USART module implements
additional features:
 automatic baud rate detection and calibration
 automatic wake-up on Sync Break reception
 12-bit Break character transmit.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 19
 The USART can be configured in the
USART
Introduction
following modes:
 Asynchronous (full duplex) with:
(cont)  Auto-wake-up on character reception
 Auto-baud calibration
 12-bit Break character transmission
 Synchronous Master (half duplex) with
selectable clock polarity
 Synchronous Slave (half duplex) with
selectable clock polarity

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 20
 The pins of the Enhanced USART are
USART multiplexed with PORTC.
Introduction
 In order to configure RC6/TX/CK and
(cont) RC7/RX/DT as an USART:
 bit SPEN (RCSTA<7>) must be set (= 1)
 bit TRISC<7> must be set (= 1)
 bit TRISC<6> must be set (= 1)
 The operation of the Enhanced USART
module is controlled through three
registers:
 Transmit Status and Control (TXSTA)
 Receive Status and Control (RCSTA)
 Baud Rate Control (BAUDCON)

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 21
Registers of
USART

TXSTA Register

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 22
Registers of
USART

RCSTA Register

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 23
Registers of
USART

BAUDCON Register

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 24
 The BRG is a dedicated, 8-bit or 16-bit
generator that supports both the
USART
Asynchronous and Synchronous modes of the
Operation
USART.
Baud Rate  By default, the BRG operates in 8-bit mode;
Generator setting the BRG16 bit (BAUDCON<3>)
(BRG) selects 16-bit mode.
 The SPBRGH:SPBRG register pair controls the
period of a free-running timer.
 In Asynchronous mode, bits, BRGH
(TXSTA<2>) and BRG16 (BAUDCON<3>),
also control the baud rate. In Synchronous
mode, BRGH is ignored.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 25
 Example
USART
Operation  Lookup table
 Baud Rate Formula
Baud Rate
Generator
(BRG)

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 26
 The Asynchronous mode of operation is
selected by clearing the SYNC bit
USART
(TXSTA<4>).
Operation
 In this mode, the USART uses standard Non-
Asynchronous Return-to-Zero (NRZ) format (one Start bit,
Mode eight or nine data bits and one Stop bit).
 The USART transmits and receives the LSB
first.
 The USARTs transmitter and receiver are
functionally independent but use the same
data format and baud rate.
 Parity is not supported by the hardware but
can be implemented in software and stored
as the 9th data bit.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 27
 USART Asynchronous Transmitter
USART
Operation  The heart of the transmitter is the
Transmit (Serial) Shift Register (TSR).
Asynchronous  The Shift register obtains its data from the
Transmitter Read/Write Transmit Buffer register,
TXREG.
 The TXREG register is loaded with data in
software.
 The TSR register is not loaded until the
Stop bit has been transmitted from the
previous load. As soon as the Stop bit is
transmitted, the TSR is loaded with new
data from the TXREG register (if available).

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 28
 This interrupt can be enabled or
USART
Operation
disabled by setting or clearing the
interrupt enable bit, TXIE (PIE1<4>).
Asynchronous  TRMT is a read-only bit which is set
Transmitter
when the TSR register is empty.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 29
To set up an Asynchronous Transmission:
USART 1. Initialize the SPBRGH:SPBRG registers for the
Operation appropriate baud rate. Set or clear the BRGH and
BRG16 bits, as required, to achieve the desired baud
rate.
Asynchronous 2. Enable the asynchronous serial port, SYNC=0 and
Transmitter SPEN=1.
3. If interrupts are desired, TXIE=1.
4. If 9-bit transmission is desired, TX9=1.
5. Enable the transmission by setting bit, TXEN, which
will also set bit, TXIF.
6. If 9-bit transmission is selected, the ninth bit should
be loaded in bit, TX9D.
7. Load data to the TXREG register (starts
transmission).
8. If using interrupts, ensure that the GIE and PEIE bits
in the INTCON register (INTCON<7:6>) are set.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 30
 USART Asynchronous Receiver
 The data is received on the RX pin and drives the
USART data recovery block.
Operation  The data recovery block is actually a high-speed
shifter operating at x16 times the baud rate,
whereas the main receive serial shifter operates at
Asynchronous the bit rate or at FOSC.
Receiver  This mode would typically be used in RS-232
systems.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 31
To set up an Asynchronous Reception:
1. Initialize the SPBRGH:SPBRG registers for the appropriate
USART baud rate. Set or clear the BRGH and BRG16 bits, as
Operation required, to achieve the desired baud rate.
2. Enable the asynchronous serial port, SYNC=0 and SPEN=1.
3. If interrupts are desired, RCIE=1.
Asynchronous 4. If 9-bit reception is desired, RX9=1.
Receiver 5. Enable the reception by CREN=1.
6. Flag bit, RCIF, will be set when reception is complete and an
interrupt will be generated if enable bit, RCIE, was set.
7. Read the RCSTA register to get the 9th bit (if enabled) and
determine if any error occurred during reception.
8. Read the 8-bit received data by reading the RCREG register.
9. If any error occurred, clear the error by clearing enable bit,
CREN.
10. If using interrupts, ensure that the GIE and PEIE bits in the
INTCON register (INTCON<7:6>) are set.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 32
 USART Functions: The following
C18 Libraries of
USART
routines are provided for devices with
a single USART peripheral:
Overall

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 33
 OpenUSART: Configure the specified USART module.
 Include: usart.h
C18 Libraries of  Prototype: void OpenUSART( unsigned char config, unsigned int
USART spbrg);
 Arguments: config
 Interrupt on Transmission:
 USART_TX_INT_ON Transmit interrupt ON
OpenUSART  USART_TX_INT_OFF Transmit interrupt OFF
 Interrupt on Receipt:
 USART_RX_INT_ON Receive interrupt ON
 USART_RX_INT_OFF Receive interrupt OFF
 USART Mode:
 USART_ASYNCH_MODE Asynchronous Mode
 USART_SYNCH_MODE Synchronous Mode
 Transmission Width:
 USART_EIGHT_BIT 8-bit transmit/receive
 USART_NINE_BIT 9-bit transmit/receive
 Slave/Master Select*:
 USART_SYNC_SLAVE Synchronous Slave mode
 USART_SYNC_MASTER Synchronous Master mode
 Reception mode:
 USART_SINGLE_RX Single reception
 USART_CONT_RX Continuous reception
 Baud rate:
 USART_BRGH_HIGH High baud rate
 USART_BRGH_LOW Low baud rate

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 34
 Arguments: spbrg
 This is the value that is written to the baud rate generator
C18 Libraries of register which determines the baud rate at which the USART
operates. The formulas for baud rate are:
USART  Asynchronous mode, high speed:
FOSC / (16 * (spbrg + 1))
 Asynchronous mode, low speed:
OpenUSART FOSC / (64 * (spbrg + 1))
 Synchronous mode:
(cont) FOSC / (4 * (spbrg + 1))
 Where FOSC is the oscillator frequency.
 Remarks: This function configures the USART module
according to the specified configuration options.
 Code Example:
 OpenUSART1( USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,
25);

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 35
 baudUSART: Set the baud rate configuration bits for enhanced
USART operation.
C18 Libraries of  Include: usart.h
USART  Prototype: void baudUSART( unsigned char baudconfig );
 Arguments: baudconfig
 Clock Idle State:
 BAUD_IDLE_CLK_HIGH Clock idle state is a high level
baudUSART  BAUD_IDLE_CLK_LOW Clock idle state is a low level
 Baud Rate Generation:
 BAUD_16_BIT_RATE 16-bit baud generation rate
 BAUD_8_BIT_RATE 8-bit baud generation rate
 RX Pin Monitoring:
 BAUD_WAKEUP_ON RX pin monitored
 BAUD_WAKEUP_OFF RX pin not monitored
 Baud Rate Measurement:
 BAUD_AUTO_ON Auto baud rate measurement enabled
 BAUD_AUTO_OFF Auto baud rate measurement disabled
 Remarks: These functions are only available for processors with
enhanced USART capability.
 Code Example:
baudUSART (BAUD_IDLE_CLK_HIGH &
BAUD_16_BIT_RATE &
BAUD_WAKEUP_ON &
BAUD_AUTO_ON);

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 36
 BusyUSART: Is the USART transmitting?
C18 Libraries of
 Include: usart.h
USART
 Prototype: char BusyUSART( void );
BusyUSART  Remarks:
 Returns a value indicating if the USART transmitter
is currently busy.
 This function should be used prior to commencing
a new transmission.
 BusyUSART should be used on parts with a single
USART peripheral.
 Return Value:
 0 if the USART transmitter is idle
 1 if the USART transmitter is in use
 Code Example: while (BusyUSART());

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 37
 WritUSART / putcUSART: Write a byte (one character)
C18 Libraries of to the USART transmit buffer, including the 9th bit if
enabled.
USART
 Include: usart.h
 Prototype:
WritUSART  void WritUSART( char data );
putcUSART  void putcUSART( char data );
 Arguments: data
 The value to be written to the USART.
 Remarks:
 This function writes a byte to the USART transmit buffer.
 If 9-bit mode is enabled, the 9th bit is written from the
field TX_NINE, found in a variable of type USART.
 Code Example:
unsigned int outval;
USART_Status.TX_NINE = (outval & 0x0100) >> 8;
Write1USART( (char) outval );

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 38
 putsUSART and putrsUSART: Writes a string of
C18 Libraries of characters to the USART including the null character.
USART  Include: usart.h
 Prototype:
 void putsUSART( char *data );
putsUSART  void putrsUSART( const rom char *data );
putrsUSART
 Arguments: data
 Pointer to a null-terminated string of data.
 Remarks:
 This function only works in 8-bit transmit/receive mode.
 This function writes a string of data to the USART
including the null character.
 Strings located in data memory should be used with the
puts versions of these functions.
 Strings located in program memory, including string
literals, should be used with the putrs versions of
these functions.
 Code Example: putrsUSART( Hello World! );

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 39
 DataRdyUSART: Is data available in
C18 Libraries of the read buffer?
USART
 Include: usart.h
DataRdyUSART  Prototype: char DataRdyUSART( void );
 Remarks: This function returns the
status of the RCIF flag bit in the PIR
register.
 Return Value:
 1 if data is available
 0 if data is not available
 Code Example:
 while (!DataRdyUSART());

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 40
 ReadUSART / getcUSART : Read a byte (one character) out of the
USART receive buffer, including the 9th bit if enabled.
 Include: usart.h
C18 Libraries of  Prototype:
 char ReadUSART( void );
USART  char getcUSART(void );
 Remarks:
 This function reads a byte out of the USART receive buffer.
ReadUSART  The Status bits and the 9th data bits are saved in a union with the
following declaration:
getcUSART union USART {
unsigned char val;
struct {
unsigned RX_NINE:1;
unsigned TX_NINE:1;
unsigned FRAME_ERROR:1;
unsigned OVERRUN_ERROR:1;
unsigned fill:4;
};
};
 The 9th bit is read-only if 9-bit mode is enabled. The Status bits are
always read.
 Return Value: This function returns the next character in the USART
receive buffer.
 Code Example:
int result;
result = ReadUSART();
result |= (unsigned int) USART_Status.RX_NINE << 8;

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 41
 getsUSART: Read a fixed-length string of characters
C18 Libraries of from the specified USART.
 Include: usart.h
USART  Prototype: void getsUSART ( char * buffer, unsigned
char len );
getsUSART  Arguments: buffer
 A pointer to the location where incoming characters are
to be stored.
 Arguments: len
 The number of characters to read from the USART.
 Remarks:
 This function only works in 8-bit transmit/receive mode.
 This function waits for and reads len number of
characters out of the specified USART.
 There is no time out when waiting for characters to
arrive.
 Code Example:
char inputstr[10];
getsUSART( inputstr, 5 );

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 42
 ClosUSART: Disable the specified
C18 Libraries of
USART
USART.
 Include: usart.h
ClosUSART
 Prototype: void ClosUSART( void );
 Remarks: This function disables the
interrupts, transmitter and receiver for
the specified USART.

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 43
#include <p18C4520.h>
#include <usart.h>
C18 Libraries of
void main(void){
USART // configure USART
OpenUSART( USART_TX_INT_OFF &
Example USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,
25 );
while(1) {
while( ! PORTAbits.RA0 ); //wait for RA0 high
WritUSART( PORTD ); //write value of PORTD
if(PORTD == 0x80) //check for termination
break; //value
}
ClosUSART();
}

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 44
1) PIC18F4520 Data Sheet
Reference 2) MPLAB C18 (v3.00) C Compiler Getting
Started
3) MPLAB C18 (v3.00) C Compiler User's Guide
4) MPLAB C18 C Compiler Libraries
5) Applying PIC18 Microcontrollers:
Architecture, Programming, and Interfacing
using C and Assembly (Hardcover) by Barry
B. Brey (Author)
6) PIC Microcontroller: An Introduction to
Software & Hardware Interfacing
(Hardcover) by Han-Way Huang (Author)
7) http://www.microchip.com/

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 45
 Ex 7-1
Ex  0.5
PORTD LED

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 46
 Ex 7-2
Ex  0.5
PORTD LED

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 47
 Ex 7-3
Ex  ,

RATE : 38400

Baud Rate
Asynchronous mode, high speed:
FOSC / (16 * (spbrg + 1))
16M/16*(25+1) 38400

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 48
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University, TAIWAN 49
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University, TAIWAN 50
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University, TAIWAN 51
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University, TAIWAN 52

Вам также может понравиться