Download Print this page
Renesas Asynchronous SH7145F Application Note
Renesas Asynchronous SH7145F Application Note

Renesas Asynchronous SH7145F Application Note

Asynchronous serial data transmission/reception

Advertisement

Quick Links

SH7145F
Asynchronous Serial Data Transmission/Reception
Summary
The SH7144 series is a single-chip microprocessor based on the SH-2 RISC (Reduced Instruction
Set Computer) CPU core and integrating a number of peripheral functions.
This application note describes asynchronous serial data transmission/reception using the SCI
(Serial Communication Interface) module of the SH7145F. It is intended to be used as reference
by users designing software applications.
The program examples contained in this application note have been tested. However, operation
should be confirmed before using them in an actual application.
Device for Which Operation Has Been Confirmed
SH7145F
Contents
1. Specifications ................................................................................................ 2
2
Functions Used ............................................................................................. 3
3. Operation....................................................................................................... 6
4. Software ........................................................................................................ 8
5. Flowcharts ..................................................................................................... 11
6. Program Listing ............................................................................................. 14
REJ06B0357-0100O/Rev.1.00
March 2004

APPLICATION NOTE

Page 1 of 17

Advertisement

loading

Summary of Contents for Renesas Asynchronous SH7145F

  • Page 1: Table Of Contents

    SH7145F Asynchronous Serial Data Transmission/Reception Summary The SH7144 series is a single-chip microprocessor based on the SH-2 RISC (Reduced Instruction Set Computer) CPU core and integrating a number of peripheral functions. This application note describes asynchronous serial data transmission/reception using the SCI (Serial Communication Interface) module of the SH7145F.
  • Page 2: Specifications

    1. Specifications As shown in figure 1, asynchronous serial data transmission is performed using channel 1 (ch1) of the SCI module of the SH7145F. In this task example 3 bytes of serial data are received by the SH7145, and the receive data is then transmitted. The communication format is 192,000 bps, 8- bit, one stop bit, and no parity.
  • Page 3: Functions Used

    Functions Used In this task example the SCI (Serial Communication Interface) is used to perform asynchronous serial data transmission/reception. Figure 2 shows a block diagram of channel 1 (ch1) of the SCI module. The functions of the elements shown in figure 2 are described below. SCI1 clock I/O pin (SCK1) External...
  • Page 4 SH7145F Asynchronous Serial Data Transmission/Reception On-Chip Peripheral Clock P This is the reference clock for operation of on-chip peripheral functions. The clock signal is generated by a clock oscillator. Receive Shift Register (RSR_1) This register is used to receive serial data. Serial data is input to RSR_1 from the RxD_1 pin. When one frame of data has been received, it is automatically transferred to the receive data register (RDR_1).
  • Page 5 Bit Rate Register (BRR_1) This 8-bit register is used to adjust the bit rate. The SCI has independent baud rate generators for the individual channels, allowing different bit rates to be set for each. See the hardware manual for details on setting values, execution rate relationships, etc. Table 2 shows the function allocations for the task example.
  • Page 6: Operation

    3. Operation Figure 3 shows the operation of asynchronous mode data transmission in the task example. To help explain figure 3, table 3 lists the software and hardware processing that is performed. TxD1 (pin) RDRF (SSR_1 bit) Receive operation Transmit operation TDR_1 (register) TSR_1...
  • Page 7 Table 3 Processing Software Processing — — Read data from RDR_1 Clear RDRF flag in SSR_1 to 0 Write receive data to TDR_1 Clear TDRE flag in SSR_1 to 1 — — — (10) — (11) Read data from RDR_1 (12) Clear RDRF flag in SSR_1 to 0 (13)
  • Page 8: Software

    4. Software (1) Module Descriptions Table 4 lists the modules used in the task example. Table 4 Module Descriptions Module Label Main routine main SCI routine init_sci Receive routine rcv_sci Transmit routine trans_sci Error handling err_int (2) Argument Descriptions Table 5 lists the arguments used in the task example. Table 5 Argument Descriptions Argument...
  • Page 9 Table 6 On-Chip Register Descriptions Register Set Value MSTCR1 MSTP17 SCR_1 H'70 MPIE TEIE CKE1 CKE2 SMR_1 H'00 STOP REJ06B0357-0100O/Rev.1.00 Asynchronous Serial Data Transmission/Reception Module standby control register 1 SCI1 standby control bit Standby cancelled when MSTP17 = 0 Serial control register 1 (SCI_1) Transmit and receive control, interrupt control, transmit and receive clock source control Transmit interrupt enable...
  • Page 10 Register Set Value SMR_1 CKS1 CKS2 BRR_1 H'40 SDCR_1 H'F2 SSR_1 H'xx TDRE RDRF ORER TEND MPBT PACRL2 PA4MD1 PA4MD0 PA3MD1 PA3MD0 *: Can only be cleared to 0. Setting to 1 is performed by hardware. REJ06B0357-0100O/Rev.1.00 Asynchronous Serial Data Transmission/Reception Multiprocessor mode (enabled in asynchronous mode only) Multiprocessor communication disabled when 0 Clock select 1, 0...
  • Page 11: Flowcharts

    5. Flowcharts (1) Main Routine REJ06B0357-0100O/Rev.1.00 Asynchronous Serial Data Transmission/Reception main() init_sci() rcv_sci() rcv_sci() rcv_sci() March 2004 Initialize SCI module Receive 1st byte of data Receive 2nd byte of data Receive 3rd byte of data SH7145F Page 11 of 17...
  • Page 12 (2) SCI1 Initialize Routine REJ06B0357-0100O/Rev.1.00 Asynchronous Serial Data Transmission/Reception init_sci() Cancel SCI1 module standby status Clear to 0 bits TIE, RIE, TE, RE, MPIE, and TEIE in SCR_0 Select on-chip clock as clock source using CKE1 and CKE0 in SCR_0 Using SMR_1, select asynchronous mode, 8 data bits, no parity, 1 stop bit, and P as baud rate generator clock...
  • Page 13 (3) Data Receive Routine (4) Data Transfer Routine REJ06B0357-0100O/Rev.1.00 Asynchronous Serial Data Transmission/Reception rcv_sci() Wait until RDR_1 finishes receiving data Read receive data from RDR_1 and store it in on-chip RAM Clear RDRF flag in SSR_1 to 0 Transmit receive data without modification trans_sci() Wait until...
  • Page 14: Program Listing

    6. Program Listing /**************************************************************/ /* SH7145F Application Note /* Function :SCI1 /* External input clock /* Internal CPU clock /* Internal peripheral clock : 25MHz /* Written /**************************************************************/ #include "iodefine.h" #include <machine.h> /*------------ Symbol Definition ----------------------------------------------*/ #define COUNT 3 /*------------ Function Definition --------------------------------------------*/ void main(void);...
  • Page 15 Function : init_sci Operation : Initialize serial (sci1) Asynchronous receive operation -Data : 8bit -Stop bit : 1bit -Parity bit : No **************************************************************/ void init_sci(void) unsigned long i; P_STBY.MSTCR1.BIT.MSTP17 = 0; /* Initialize SCI Asynchronous mode * P_SCI1.SCR_1.BYTE &= 0x03 ; P_SCI1.SCR_1.BIT.CKE = 0;...
  • Page 16 P_SCI1.SSR_1.BIT.RDRF = 0; trans_sci(Rev_data[rev_count]); rev_count++ ; return(rev_count); /************************************************************************/ Function : trans_sci Operation : Write 1 character to serial output Argument : trans_data Value returned : None /************************************************************************/ void trans_sci(char tarans_data) { while(!(P_SCI1.SSR_1.BYTE & 0x80)){ /* Wait until data can be written to TDR */ P_SCI1.TDR_1 = (unsigned char)trans_data;...
  • Page 17 (iii) prevention against any malfunction or mishap. 1. These materials are intended as a reference to assist our customers in the selection of the Renesas Technology Corp. product best suited to the customer's application; they do not convey any license under any intellectual property rights, or any other rights, belonging to Renesas Technology Corp.