Home
RX210, RX21A, and RX220 Groups
Contents
1. Page 13 of 36 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI Table 5 10 Constants Used in the Sample Code when SELECT_SCI8 is Selected in sci_cfg h Constant Name SClIn Setting Value SCI8 Contents SCI channel SCI8 MSTP_SCln MSTP SCI8 SCI8 module stop setting bit IPR_SClIn IPR SCI8 SCI8 interrupt priority level setting bit IR_SCIn_ERIn IR SCI8 ERI8 SCI8 ERI8 interrupt status flag IR_SCIn_RXiIn IR SCI8 RXI18 SCI8 RXI8 interrupt status flag IR_SCIn_TXIn IR SCI8 TXI18 SCI8 TX18 interrupt status flag IR_SCIn_TEIn IR SCI8 TEI8 SCI8 TEI8 interrupt status flag IEN_SCIn_ERIn IEN SCI8 ERI8 SCI8 ERI8 interrupt request enable bit IEN_SCIn_RXiIn SCI8 RXI8 interrupt request enable bit IEN_SCIn_TXIn IEN SCI8 RX18 IEN SCI8 TX18 SCI8 TXI 8 interrupt request enable bit IEN_SCIn_TEIn IEN SCI8 TEI8 SCI8 TEI8 interrupt request enable bit RXDn PDR PORTC PDR BIT B6 PC6 I O select bit RXDn PMR PORTC PMR BIT B6 PC6 pin mode control bit RXDnPFS PC6PFS PC6 pin function control register TXDn_PODR PORTC PODR BIT B7 PC7 output data store bit TXDn_PDR PORTC PDR BIT B7 PC7 I O select bit TXDn_PMR PORTC PMR BIT B7 PC7 pin mode control bit TXDnPFS PC7PFS PC7 pin function control register PSEL_SETTING OAh Setting v
2. RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI Table 5 8 Constants Used in the Sample Code when SELECT_SCI5 is Selected in sci_cfg h Constant Name SClIn Setting Value SCI5 Contents SCI channel SCI5 MSTP_SCln MSTP SCI5 SCI5 module stop setting bit IPR_SClIn IPR SCI5 SCI5 interrupt priority level setting bit IR_SCIn_ERIn IR SCI5 ERI5 SCI5 ERI5 interrupt status flag IR_SCIn_RXiIn IR SCI5 RXI15 SCI5 RXI5 interrupt status flag IR_SCIn_TXIn IR SCI5 TXI5 SCI5 TXI5 interrupt status flag IR_SCIn_TEIn IR SCI5 TEI5 SCI5 TEI5 interrupt status flag IEN_SCIn_ERIn IEN SCI5 ERIS SCI5 ERI5 interrupt request enable bit IEN_SCIn_RXIn IEN SCI5 RXI5 SCI5 RXI5 interrupt request enable bit IEN_SCIn_TXIn IEN SCI5 TXI5 SCI5 TXI5 interrupt request enable bit IEN_SCIn_TEIn IEN SCI5 TEIS SCI5 TEI5 interrupt request enable bit RXDn PDR PORTA PDR BIT B3 PA3 I O select bit RXDn PMR PORTA PMR BIT B3 PA3 pin mode control bit RXDnPFS PA3PFS PA3 pin function control register TXDn_PODR PORTA PODR BIT B4 PA4 output data store bit TXDn_PDR PORTA PDR BIT B4 PA4 I O select bit TXDn_PMR PORTA PMR BIT B4 PA4 pin mode control bit TXDnPFS PA4PFS PA4 pin function control register PSEL_SETTING OAh Setting value of the pin function s
3. 3 Reference Application Notes For additional information associated with this document refer to the following application notes RX210 Group Initial Setting Rev 2 00 ROLAN1002EJ RX21A Group Initial Setting Rev 1 10 ROLAN1486EJ RX220 Group Initial Setting Rev 1 10 ROLAN1494EJ The initial setting functions in the reference application notes are used in the sample code in this application note The revision numbers of the reference application notes are current as of when this application note was made However the latest version is always recommended Visit the Renesas Electronics Corporation website to check and download the latest version RO1AN1423EJ0101 Rev 1 01 July 1 2014 RENESAS Page 4 of 36 RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 4 Hardware 4 1 Pins Used Table 4 1 lists the Pins Used and Their Functions The number of pins in the sample code is set for the 100 pin package When using products with less than 100 pins select pins appropriate to the package used Table 4 1 Pins Used and Their Functions Pin Name Function LEDO output completion of SCI transmission P15 LED output completion of SCI reception P16 LED2 output SCI reception error P21 RXDO Input pin for SCIO receive data P20 TXDO P15 RXD1 Output pin for SCIO transmit data NW Input pin for SCI1 receive data P16 TXD1 Output pin for SCH transmit data PA
4. SCI_StartReceive Arguments l uint8_t pbuf Pointer to the receive data storage uint8_t num Number of bytes to be received CallBackFunc pcb_rx_end Pointer to the callback function SCI receive end CallBackFunc pcb_rx_error Pointer to the callback function SCI receive error Set the return value return_value SCI_LNG argument error s the number of bytes to be received 0 return return_value Is the reception status busy Reads B_RX_BUSY 0 Reception ready No 1 Reception busy Set the receive busy flag B_RX_BUSY lt 1 Set the return value SCI reception being processed B_RX_ORER lt 0 return_value SCI_BUSY Clear the receive error flags B RX FER lt 0 Set the arguments to the RAM pbuf_rx pbuf rx_cnt num pcb_sci_rx_end lt pcb_rx_end pcb_sci_rx_error lt pcb_rx_error Enable RXI and ERI SCin SCR register interrupt requests RIE bit 1 e SCin SCR register Enable serial reception RE bit 1 Enable SCIn RXIn and IER1A register D SCiIn ERIn interrupt requests IEN6 bit lt 1 IEN7 bit 1 Set the return value return_value SCI_OK SCI reception started T return return_value Note 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O register specified depends on the SCI channel selected in the configuration file Figure 5 13 User Interface Function SCI Receive Start RO1AN1423EJ0101 Rev 1 01 Page 27 of 36 July 1 201
5. Yes 8 mm SCIn SCR register Disable serial reception RE bit lt 0 Disable SCIn RXIn and IER1A register SCIn ERIn interrupt requests IENG bit lt 0 IEN7 bit 0 Reads rx_cnt Disable the RXI and ERI interrupt SCIn SCR register requests RIE bit 0 Clear the SCIn RXIn IR215 register interrupt request IR flag lt 0 Clear the receive busy flag B_RX_BUSY lt 0 Callback function SCI receive end pcb_sci_rx_end Notes 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O registers specified depend on the SCI channel selected in the configuration file 2 After writing values to bits RE and RIE read these bits to confirm that the written values can be read Figure 5 18 Receive Data Full Interrupt RO1AN1423EJ0101 Rev 1 01 Page 31 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 14 Receive Error Interrupt Figure 5 19 shows the Receive Error Interrupt sci_eri_isr Has an overrun Reads the SCIn SSR register error occurred ORER flag 0 No overrun error occurred 1 An overrun error occurred Set the overrun error flag B_RX_ORER lt 1 Has a framing Reads the SCIn SSR register error occurred FER flag 0 No framing error occurred 1 A framing error occurred Set the framing error flag B_RX_FER lt 1 Dummy read the RDR register Reads the SCIn RDR register F WEN SClIn SCR
6. Rev 1 01 July 1 2014 Setting value of the pin function select bit RXD9 TXD9 Page 14 of 36 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI Table 5 12 Constants Used in the Sample Code when SELECT_SCI12 is Selected in sci_cfg h Constant Name SClIn Setting Value SCIl12 Contents SCI channel SCI12 MSTP_SCln MSTP SCI12 SCI12 module stop setting bit IPR_SClIn IPR SCI12 SCI12 interrupt priority level setting bit IR_SCIn_ERIn IR SCI12 ERI12 CI12 ERI12 interrupt status flag IR_SCIn_RXiIn SCI12 RX112 interrupt status flag IR_SCIn_TXIn IR SCI12 TX112 CI12 TX112 interrupt status flag IR_SCIn_TEIn IR SCI12 RX112 IR SCI12 TEIM12 CI12 TEI12 interrupt status flag IEN_SCIn_ERIn IEN SCI12 ERI12 SCI12 ERI12 interrupt request enable bit IEN Scho Bxin IEN SCI12 RX112 SCI12 RX112 interrupt request enable bit IEN_SCIn_TXIn IEN SCI12 TXI12 SCI12 TX1I12 interrupt request enable bit IEN_SCIn_TEIn IEN SCI12 TEI2 SCI12 TEI12 interrupt request enable bit RXDn PDR PORTE PDR BIT B2 DEZ UO select bit RXDn PMR PORTE PMR BIT B2 PE2 pin mode control bit RXDnPFS PE2PFS PE2 pin function control register TXDn_PODR PORTE PODR BIT B1 PE1 output data store bit TXDn_PDR PORTE PDR BIT B1 PE1 I O select bit TXDn PMR PORTE PMR BIT B1 PE1
7. file 2 After writing a value to the TIE bit read the bit to confirm that the written value can be read Figure 5 16 Transmit Data Empty Interrupt RO1AN1423EJ0101 Rev 1 01 Page 29 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 12 Transmit End Interrupt Figure 5 17 shows the Transmit End Interrupt oe as pin as general I O port ee a Disable the SCIn TEIn IER1B register interrupt request IEN1 bit lt 0 ml SCIn SCR register Disable the TEI interrupt request TEIE bit lt 0 Clear the transmit busy flag B_TX_BUSY lt 0 Callback function SCI transmit end pcb_sci_tx_end return Notes 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O registers specified depend on the SCI channel selected in the configuration file 2 After writing a value to the TEIE bit read the bit to confirm that the written value can be read Figure 5 17 Transmit End Interrupt RO1AN1423EJ0101 Rev 1 01 Page 30 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 13 Receive Data Full Interrupt Figure 5 18 shows the Receive Data Full Interrupt sci_rxi_isr Store the receive data pbuf_rx lt SCIn RDR register Pointer to the receive buffer 1 pbuf_rx lt pbuf_rx 1 Receive counter 1 rx_cnt lt rx_cnt 1 Has the last data been received
8. pbuf Pointer to the receive data storage uint8_t num Number of bytes to be received CallBackFunc pcb_rx_end Pointer to the callback function SCI receive end CallBackFunc pcb_rx_error Pointer to the callback function SCI receive error SCI_NG Argument error number of bytes to be received is 0 SCI_BUSY SCI reception being processed SCI_OK SCI reception started RO1AN1423EJ0101 Rev 1 01 July 1 2014 Page 19 of 36 RENESAS RX210 RX21A and RX220 Groups SCI_StartTransmit Outline Header Declaration Description Arguments Return Value SCI_GetState Outline Header Declaration Description Arguments Return Value sci_txi_isr Outline Header Declaration Description Arguments Return Value sci_tei_isr Outline Header Declaration Description Arguments Return Value Asynchronous Communication Using the SCI User interface function SCI transmit start sci h uint8_t SCI_StartTransmit const uint8_t pbuf uint8_t num CallBackFunc pcb_tx_end Starts SCI transmission const uint8_t pbuf Pointer to the transmit data storage uint8_t num Number of bytes to be transmitted CallBackFunc pcb_tx_end Pointer to the callback function transmit end SCI_NG Argument error number of bytes to be transmitted is 0 SCI_BUSY SCI transmission being processed SCI_OK SCI transmission started User interface function SCI state obtain sci h sci_state_t SCl_GetState void Returns the SCI state Non
9. register Disable serial reception RE bit lt 0 SCin SSR register SCIn SSR register amp C7h COh PER flag 0 No parity error occurred FER flag 0 No framing error occurred ORER flag 0 No overrun error occurred Clear error flags Disable the SCIn RXIn and IER1A register SCin ERIn interrupt requests IENG bit lt 0 IEN7 bit lt 0 Disable the RXI and ERI SCiIn SCR register interrupt requests RIE bit 0 Clear the SCIn RXIn IR215 register 1 interrupt request IR flag lt 0 Clear the receive busy flag B_RX_BUSY lt 0 Callback function SCI receive error pcb_sci_rx_error return Notes 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O registers specified depend on the SCI channel selected in the configuration file 2 After writing values to bits RE and RIE and flags PER FER and ORER read these bits and flags to confirm that the written values can be read Figure 5 19 Receive Error Interrupt RO1AN1423EJ0101 Rev 1 01 Page 32 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 15 SCI ERI Interrupt Handling Figure 5 20 shows the SCI ERI Interrupt Handling Excep_SCIn_ERIn Interrupt Determine requested the interrupt request i Solirce Reads the SCIn SCR register RIE bit 0 RXI and ERI interrupt requests are disabled 1 RXI and ERI interrupt requests are enabled Reads
10. the SCIn SSR register PER flag 0 No parity error occurred 1 A parity error has occurred FER flag 0 No framing error occurred 1 A framing error has occurred ORER flag 0 No overrun error occurred 1 An overrun error has occurred Receive error interrupt sci_eri_isr Verify the IR flag Reads the IR214 register IR flag 0 No interrupt request is generated 1 Interrupt request is generated Interrupt not requested Note 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O register read depends on the SCI channel selected in the configuration file Figure 5 20 SCI ERI Interrupt Handling 5 9 16 SCI RXI Interrupt Handling Figure 5 21 shows the SCI RXI Interrupt Handling Excep_SCIn_RXIn Receive data full interrupt sci_rxi_isr return Figure 5 21 SCI RXI Interrupt Handling RO1AN1423EJ0101 Rev 1 01 Page 33 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 17 SCI TXI Interrupt Handling Figure 5 22 shows the SCI TXI Interrupt Handling Excep_SCIn_TXIn Transmit data empty interrupt sci_txi_isr return Figure 5 22 SCI TXI Interrupt Handling 5 9 18 SCI TEI Interrupt Handling Figure 5 23 shows the SCI TEI Interrupt Handling Excep_SCIn_TEIn 3 Interrupt Determine requested the interrupt request i BE Reads the SCIn SCR register TEIE bit 0 A TEI interrupt reques
11. www renesas com for the latest and detailed information Renesas Electronics America Inc 2801 Scott Boulevard Santa Clara CA 95050 2549 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada Tel 1 905 898 5441 Fax 1 905 898 3220 Renesas Electronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 585 100 Fax 44 1628 585 900 Renesas Electronics Europe GmbH Arcadiastrasse 10 40472 D sseldorf Germany Tel Renesas Electronics China Co Ltd Room 1709 Quantum Tel 49 211 6503 0 Fax 49 211 6503 1327 laza No 27 ZhiChunLu Haidian District Beijing 100191 P R China 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 301 Tower A Central Towers 555 Langao Road Putuo District Shanghai P R China 200333 Tel 86 21 2226 0888 Fax 86 21 2226 0999 Renesas Electronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2265 6688 Fax 852 2886 9022 9044 Renesas Electronics Taiwan Co Ltd 13F No 363 Fu Shing North Road Taipei 10543 Taiwan Tel 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd 80 Tel Bendemeer Road Unit 06 02 Hyflux Innovation Centre Singapore 339949 65 621
12. 3 0200 Fax 65 6213 0300 Renesas Electronics Malaysia Sdn Bhd Unit 906 Block B Menara Amcorp Amcorp Trade Centre No 18 Jin Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Electronics Korea Co Ltd 12F 234 Teheran ro Gangnam Ku Seoul 135 920 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2014 Renesas Electronics Corporation All rights reserved Colophon 4 0
13. 3 RXD5 Input pin for SCI5 receive data PA4 TXD5 PBO RXD6 Output pin for SCI5 transmit data NW Input pin for SCI6 receive data PB1 TXD6 Output pin for SCI6 transmit data PC6 RXD8 Input pin for SCI8 receive data PC7 TXD8 PB6 RXD9 Output pin for SCI8 transmit data NW Input pin for SCI9 receive data PB7 TXD9 Output pin for SCI9 transmit data NW PE2 RXD12 Input pin for SCI12 receive data PE1 TXD12 Note Output pin for SCI12 transmit data a 1 The SCI pins used depend on the SCI channel selected in the configuration file Unused SCI pins can be used as general I O ports R01AN1423EJ0101 Rev 1 01 July 1 2014 RENESAS Page 5 of 36 RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 Software After a reset the user interface function SCI initialization is called to initialize the SCI When the user interface function SCI receive start is called receive operation is enabled When data for the specified number of bytes have been received the SCI receive operation is disabled and the callback function SCI receive end is called LED1 is turned on with the callback function SCI receive end When a receive error occurs the SCI receive operation is disabled and the callback function SCI reception error is called LED2 is turned on with the callback function SCI receive error When the user interface function SCI transmit st
14. 4 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 9 User Interface Function SCI Transmit Start Figure 5 14 shows the User Interface Function SCI Transmit Start SCI_StartTransmit Arguments l uint8_t pbuf Pointer to the transmit data storage uint8_t num Number of bytes to be transmitted CallBackFunc pcb_tx_end Pointer to the callback function SCI transmit end Set the retum value return_value SCI_NG argument error s the number of bytes to be transmitted 0 return return_value s the transmission status busy Reads B_TX_BUSY 0 Transmission ready 1 Transmission busy No Set the transmit busy flag B_TX_BUSY lt 1 Set the return value SCI transmission being processed Set the arguments to the RAM pbuf_t lt pbuf PER tx_cnt lt num pcb_sci_tx_end lt pcb_tx_end Enable the TXI interrupt request SCln SCR register TIE bit lt 1 e or SCiIn SCR register Enable serial transmission TE bit lt 1 PORT2 PMR register Settheport mode BO bit lt 1 Uses the pin as I O port for peripheral function Enable the SCIn TXIn IER1B register 11 interrupt request IENO bit lt 1 Set the return value return_value lt SCI_OK SCI transmission started Ee EE return return_value Note 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O registers specified depend on the SCI channel selected in the
15. CI transmit start SCI_GetState User interface function SCI state obtain sci_txi_isr Transmit data empty interrupt sci_tei_isr sci_rxi_isr Transmit end interrupt Receive data full interrupt sci_eri_isr Receive error interrupt Excep_SClIn_ERIn SCI ERI interrupt handling Excep_SClIn_RX In Excep_SClIn_TXIn SCI RXI interrupt handling SCI TXI interrupt handling Excep_SClIn_TEIn 5 8 SCI TEI interrupt handling Function Specifications The following tables list the sample code function specifications main Outline Header Declaration Description Arguments Return Value port_init Outline Header Declaration Description Arguments Return Value Main processing None void main void After initialization starts SCI reception and then starts transmission None None Port initialization None static void port_init void Initializes the ports None None RO1AN1423EJ0101 Rev 1 01 July 1 2014 Page 17 of 36 RENESAS RX210 RX21A and RX220 Groups R_INIT_StopModule Outline Header Declaration Description Arguments Return Value Remarks Asynchronous Communication Using the SCI Stop processing for active peripheral functions after a reset r_init_stop_module h void R_INIT_StopModule void Configures the setting to enter the module stop state None None Transition to the module stop state is not performed in the sample code For details o
16. EC WEN e e El CT ER 59 1 Main ee Lu e EE ER 5 9 2 Port Initialization 0 00 2 ee cece cece cee ee cece ee cece cece tec aeaeeeee eee ceaaaaeaeeeeeeeseeeaaaeseeeeeesenscccaeeeeeeeeeeeees 23 5 9 3 Peripheral Function Inmtaltzaton eee eeeeeeceeeeeeeeeeesececeaeeeeeeeeesenenaeeeeeeeeeeeee 23 5 9 4 Callback Function SCI Transmit End 0 cceeeeceeeeeeeneeeeeenneeeeeeaeeeeetaeeeeeteeeeeesiaeeeeneaes 23 5 9 5 Callback Function SCI Receive End 24 5 9 6 Callback Function SCI Receive Error 24 5 9 7 User Interface Function SCI Intaltzaton eee ee eeeeeeeeeeeeneeeeeeeaeeeeetaeeeetneeeeeneaes 25 5 9 8 User Interface Function SCI Receive Grat 27 5 9 9 User Interface Function SCI Transmit Grant 28 5 9 10 User Interface Function SCI State Obtam eee eeeeeee eee eeneeeeeeeeeeetnaeeeetieeeeeneaes 29 5 9 11 Transmit Data Empty Interupt cee eeeeeececeeeeeeeeeeseceaeeeeeeeeeesecseaeeeeeenseteees 29 5 9 12 Transmit End nterrupt niinniin iada auaina adanida aaa ibaian iei 30 5 9 13 Receive Data Full Interrupt AN 31 5 9 14 Receive Error lnterupt nnns tttttnn nnns a ntr EnEn nn annen nnne ent 32 5 9 15 SCLERI interrupt Randlmg esdteeetee eege dE EE E EEEE E 33 5 9 16 SCI RXI Interrupt Handling eeee een eee eeeeeeeeeeaeeeeeeaaeeeeeaeeeeseeaeeeseeneeeseeneeeeeaas 33 99 10 SC ts Interrupt ANGlin G eisgeegeiEesggecu ee deesged eege eege deeg eege Deeg 34 9 9 18 SCI TELInterrupt Handling 22 stiseeceeeeeiesne ieee de aveetich eet ae ASSA
17. ER sci_state bit b_rx_fer RO1AN1423EJ0101 Rev 1 01 July 1 2014 Framing error flag 0 Framing error not occurred 1 Framing error occurred RENESAS Page 10 of 36 RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI Table 5 4 Constants Used in the Sample Code sci c Constant Name Setting Value Contents SSR_ERROR_FLAGS 38h Bit pattern of an error flag in the SCI SSR register Transmit busy flag B_TX_BUSY state bit b_tx_busy 0 Transmission ready 1 Transmission busy Receive busy flag B_RX_BUSY state bit b_rx_busy 0 Reception ready 1 Reception busy Overrun error flag D RX_ORER state bit b_rx_orer 0 Overrun error not occurred 1 Overrun error occurred Framing error flag B RX_FER state bit b_rx_fer 0 Framing error not occurred 1 Framing error occurred Table 5 5 Constants Used in the Sample Code sci h Constant Name Setting Value Contents Return value of the SCI_StartTransmit and SCI StartReceive SCT OR functions SCI transmit receive start Return value of the GC StartTransmit and SCI StartReceive SCI_BUSY functions SCI transmission or reception being processed Return value of the SCI_StartTransmit and SCI StartReceive SCI_NG functions Argument error number of bytes to be transmitted received is 0 RO1AN1423EJ0101 Rev 1 01 Page 11 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI Tab
18. FFh Little endian FFFF FF8Fh to FFFF FF8Ch FFFF FFFFh RO1AN1423EJ0101 Rev 1 01 Page 9 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups 5 4 Constants Table 5 3 to Table 5 12 list the Constants Used in the Sample Code Table 5 3 Constants Used in the Sample Code main c Constant Name LEDO REG PODR Setting Value PORT1 PODR BIT B4 Contents LEDO output data store bit Asynchronous Communication Using the SCI LEDO REG PDR PORT1 PDR BIT B4 LEDO I O select bit LEDO_ REG PMR LED1 REG PODR PORT1 PMR BIT B4 PORT1 PODR BIT B5 LEDO pin mode control bit LED output data store bit LED REG PDR PORT1 PDR BIT B5 LED1 I O select bit LED1 REG PMR PORT1 PMR BIT B5 LED pin mode control bit LED2 REG PODR LED2 REG PDR PORT1 PODR BIT B6 PORT1 PDR BIT B6 LED2 output data store bit LED2 I O select bit LED2 REG PMR PORT1 PMR BIT B6 LED2 pin mode control bit LED ON LED output data Turned on LED OFF BUF_SIZE LED output data Turned off Buffer size NULL_SIZE NULL code size SCI_B_TX_BUSY sci_state bit b_tx_busy Transmit busy flag 0 Transmission ready 1 Transmission busy SCI_B_RX_BUSY sci_state bit b_rx_busy Receive busy flag 0 Reception ready 1 Reception busy SCI_B_RX_ORER sci_state bit b _rx_orer Overrun error flag 0 Overrun error not occurred 1 Overrun error occurred SCI_B_RX_F
19. SCI transmit end Transmit busy flag SCR TIE bit SCR TE bit Sets the TXD pin mode Sets the TE bitto 1 and Control bit to 0 and then then sets the TXD pin ets the TE bit to 0 mode control bit to 1 SCR TEIE bit Sets to 1 by a program Sets to 0 by a program Becomes 0 by an interrupt acceptance IEN bit for the TXI interrupt IR flag for the TXI interrupt IEN bit for the TEI interrupt IR flag for the TEI interrupt TXD pin mode control bit PMR register 1 O O ech O ech O a O a ose On On O General General General input port output port output port lt 4 Ka Pid k gt ae Transmit data Hello world 1 The bit specified depends on the SCI channel selected Figure 5 2 Timing of Serial Transmission RO1AN1423EJ0101 Rev 1 01 Page 7 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 1 2 Serial Reception Figure 5 3 shows the Timing of Serial Reception and 1 to 4 in the figure correspond to numbers in the operation descriptions below 1 Initialization Initializes the SCI using the user interface function SCI initialization and switches the RXD pin function to RXD input 2 Starting a reception Verifies the receive busy flag B_ RX BUSY using the user interface function SCI receive start When the flag is 1 reception busy SCI BUSY SCI reception being processed is returned When the flag is 0 reception ready sets the r
20. SE AE 34 6 Applying This Application Note to the RX21A or RX220 Group 35 Te Sample Code ccna e AT N EE A tain be eat eda nance aes ean 36 8 Reference DocuUmeENiS arsons E a EERSTEN E TE 36 R01AN1423EJ0101 Rev 1 01 Page 2 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 1 Specifications Asynchronous serial transmission and reception are performed using the SCI After a reset transmission and reception are performed only once each 12 bytes of character code spelling out Hello world is transmitted from the transmit buffer When the 12 byte transmission is completed LEDO is turned on The 12 byte data is received and stored in the receive buffer When the 12 byte reception is completed LED1 is turned on If an error occurs during reception the receive operation is terminated and LED2 is turned on The SCI channel used is selected in the configuration file Channel 0 SCIO is selected in the sample code Transfer rate 57600 bps Data length 8 bits Stop bit 2 bits Parity None Hardware flow control None Table 1 1 lists the Peripheral Functions and Their Applications and Figure 1 1 shows a Usage Example Table 1 1 Peripheral Functions and Their Applications Peripheral Function Application SCI selectable from 0 1 5 6 8 9 and 12 Asynchronous serial transmission and reception I O ports Turn on LEDs Renesas Starter Kit for RX210 Terminal softwar
21. addition is not performed CHR bit 0 Selects 8 bits as the data length CM bit 0 Asynchronous mode Set the transmit receive format SCln SCMR register lt F2h SMIF bit 0 Serial communications interface mode SINV bit 0 TDR contents are transmitted as they are Receive data is stored as it is in RDR SDIR bit 0 Transfer with LSB first SCIn SEMR register lt 00h ABCS bit 0 Selects 16 base clock cycles for 1 bit period NFEN bit 0 Noise cancellation function for the RXDn input signal is disabled Set the bit rate SCIn BRR register lt 13 25 MHz 64 x CR x 57600 bps 1 12 56 B IPR214 register Set the SCIn int t ty level et ine St in Interrupt priority eve IPR 3 0 bits 0001b Level 1 IR215 register Clear the SCIn int t t SEN ee es IR flag lt 0 No SCIO RXIO interrupt request is generated IR216 register IR flag lt 0 No SCIO TXIO interrupt request is generated Note 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O registers specified depend on the SCI channel selected in the configuration file Figure 5 12 User Interface Function SCI Initialization 2 2 RO1AN1423EJ0101 Rev 1 01 Page 26 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 8 User Interface Function SCI Receive Start Figure 5 13 shows the User Interface Function SCI Receive Start
22. alue of the pin function select bit RXD8 TXD8 Table 5 11 Constants Used in the Sample Code when SELECT_SCI9 is Selected in sci_cfg h d Constant Name SCln Setting Value SCI9 Contents SCI channel SCI9 MSTP_SClIn MSTP SCI9 SCI9 module stop setting bit IPR_SClIn IPR SCI9 SCI9 interrupt priority level setting bit IR_SCIn_ERIn IR SCI9 ERI9 SCI9 ERIQ interrupt status flag IR_SCIn_RXiIn IR SCI9 RXI19 SCI9 RXI9 interrupt status flag IR_SCIn_TXIn IR SCI9 TXI9 SCI9 TXI9 interrupt status flag IR_SCIn_TEIn IR SCI9 TEI9 SCI9 TEI9 interrupt status flag IEN_SCiIn_ERIn IEN SCI9 ERI9 SCI9 ERIQ interrupt request enable bit IEN_SCIn_RXiIn IEN SCI9 RXI9 SCI9 RXI9 interrupt request enable bit IEN_SCIn_TXIn SCI9 TXI9 interrupt request enable bit IEN_SCIn_TEIn IEN SCI9 TXI9 IEN SCI9 TEI9 SCI9 TEI9 interrupt request enable bit RXDn_PDR PORTB PDR BIT B6 PB6 I O select bit RXDn_PMR PORTB PMR BIT B6 PB6 pin mode control bit RXDnPFS PB6PFS PB6 pin function control register TXDn_PODR PORTB PODR BIT B7 PB7 output data store bit TXDn_PDR PORTB PDR BIT B7 PB7 I O select bit TXDn_PMR PORTB PMR BIT B7 PB7 pin mode control bit TXDnPFS PB7PFS PB7 pin function control register PSEL_SETTING Note 1 SCI9 is not available in 48 pin products OAh RO1AN1423EJ0101
23. art is called the transmit operation is enabled When data for the specified number of bytes have been transmitted the SCI transmit operation is disabled and the callback function SCI transmit end is called LEDO is turned on with the callback function SCI transmit end Peripheral function settings are shown below and Figure 5 1 shows the Software Configuration SCI Serial communication mode Asynchronous operation Transfer rate 57600 bps Clock source PCLKB 25 MHz Data length 8 bits Stop bit 2 bits Parity None Interrupts Receive error interrupt ERI enabled Receive data full interrupt RXT enabled Transmit data empty interrupt TXI enabled Transmit end interrupt TEI enabled Main processing main c Asynchronous communication sci c User interface function SCI state obtain Palen ee a agp ae ee OE eT al Transmit data empty interrupt e UNGON ce J mpare SS i e e i H External function internal function gt global Calls functions Figure 5 1 Software Configuration RO1AN1423EJ0101 Rev 1 01 Page 6 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 1 Operation Overview 5 1 1 Serial Transmission Figure 5 2 shows the Timing of Serial Transmission and 1 to 4 in the figure correspond to numbers in the operation descriptions below 1 Initialization Initializes the SCI using the user interface function SCI initializatio
24. bject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or systems manufactured by you Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations You should not use Renesas Electronics products or technology described in this document for any purpose relating to military applications or use by
25. configuration file Figure 5 14 User Interface Function SCI Transmit Start RO1AN1423EJ0101 Rev 1 01 Page 28 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 10 User Interface Function SCI State Obtain Figure 5 15 shows the User Interface Function SCI State Obtain SCI_GetState Set the SCI state as the return value return state Figure 5 15 User Interface Function SCI State Obtain 5 9 11 Transmit Data Empty Interrupt Figure 5 16 shows the Transmit Data Empty Interrupt sci_txi_isr Set the transmit data SCiIn TDR register lt pbuf_tx Dummy read the SSR register Reads the SCIn SSR register and performs calculations Pointer to the transmit buffer 1 pbuf_tx pbuf_tx 1 Transmit counter 1 tx_cnt tx_cnt 1 Is the data transmitted Reads tx cnt the last data 7 Yes Disable the SCIn TXIn IER1B register interrupt request IENO bit lt 0 SCiIn SCR register i i 2 Disable the TXI interrupt request TIE bit lt 0 Clear the SCIn TXIn IR216 register UI interrupt request IR flag 0 SCiIn SCR register Enable the TEI interrupt request TEIE bit lt 1 Enable the SCIn TEIn IER1B register interrupt request IEN1 bit lt 1 return Notes 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O registers specified depend on the SCI channel selected in the configuration
26. cted Figure 5 3 Timing of Serial Reception RO1AN1423EJ0101 Rev 1 01 Page 8 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 2 File Composition Table 5 1 lists the Files Used in the Sample Code Files generated by the integrated development environment are not included in this table Table 5 1 Files Used in the Sample Code File Name Outline Remarks main c Main processing Stop processing for active peripheral functions after a reset r_init_stop_module h Header file for r_init_stop_module c r_init_non_existent_port c Nonexistent port initialization r_init_non_existent_port h Header file for r_init_non_existent_port c r_init_clock c Clock initialization r_init_clock h Header file for r_init_clock c SCC Asynchronous communication sci h Header file for sci c sci_cfg h Header file for sci c configuration file SCI channel selection r_init_stop_module c 5 3 Option Setting Memory Table 5 2 lists the Option Setting Memory Configured in the Sample Code When necessary set a value suited to the user system Table 5 2 Option Setting Memory Configured in the Sample Code Address Setting Value Contents The IWDT is stopped after a reset The WDT is stopped after a reset The voltage monitor 0 reset is disabled FFFF FF8Bh to FFFF FF88h FFFF FFFFh after a reset HOCO oscillation is disabled after a reset FFFF FF83h to FFFF FF80h FFFF FF
27. ded nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury artificial life support devices or systems surgical implantations etc or may cause serious property damages nuclear reactor control systems military equipment etc You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application for which itis not intended Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Further Renesas Electronics products are not su
28. e Hello world LEDO output LED output RS232C LED2 output Computer Figure 1 1 Usage Example RO1AN1423EJ0101 Rev 1 01 Page 3 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 2 Operation Confirmation Conditions The sample code accompanying this application note has been run and confirmed under the conditions below Table 2 1 Operation Confirmation Conditions Item Contents MCU used R5F52108ADFP RX210 Group Operating frequencies Operating voltage Main clock 20 MHz PLL 100 MHz main clock divided by 2 and multiplied by 10 System clock ICLK 50 MHz PLL divided by 2 Peripheral module clock B PCLKB 25 MHz PLL divided by 4 5 0 V Integrated development environment Renesas Electronics Corporation High performance Embedded Workshop Version 4 09 01 C compiler Renesas Electronics Corporation C C Compiler Package for RX Family V 1 02 Release 01 Compile options cpu rx200 output obj CONFIGDIR FILELEAF obj debug nologo The default setting is used in the integrated development environment iodefine h version Version 1 2A Endian Little endian Operating mode Single chip mode Processor mode Supervisor mode Sample code version Version 1 00 Board used Renesas Starter Kit for RX210 product part no ROK505210COOOBE Tool used Terminal software
29. e sci_state_t bit b_tx_busy Transmit busy flag 0 Transmission ready 1 Transmission busy sci_state_t bit b_rx_busy Receive busy flag 0 Reception ready 1 Reception busy sci_state_t bit b_rx_orer Overrun error flag 0 Overrun error not occurred 1 Overrun error occurred sci_state_t bit b_rx_fer Framing error flag 0 Framing error not occurred 1 Framing error occurred Transmit data empty interrupt None static void sci_txi_isr void This function is called in the SCI TXI interrupt handling Writes the transmit data After transmitting the last data disables the TXI interrupt request and enables TEI interrupt request None None Transmit end interrupt None static void sci_tei_isr void This function is called in the SCI TEI interrupt handling Disables the serial transmission and calls the callback function SCI transmit end None None R01AN1423EJ0101 Rev 1 01 July 1 2014 Page 20 of 36 RENESAS RX210 RX21A and RX220 Groups sci_rxi_isr Outline Header Declaration Description Arguments Return Value sci_eri_isr Outline Header Declaration Description Arguments Return Value Excep_ SClIn_ERIn Outline Header Declaration Description Arguments Return Value Excep_ SClIn_RXin Outline Header Declaration Description Arguments Return Value Excep_SClIn_TXIn Outline Header Declaration Description Arguments Return Value Excep_SClIn_TEIn Outline Header Declarati
30. eceive busy flag to 1 and clears the error flags Sets the SCR RIE bit to 1 RXI and ERI interrupt requests are enabled the SCR RE bit to 1 serial reception is enabled and the IEN bit for the RXI and ERI interrupts to 1 interrupt request is enabled 3 Receiving data When data is received an RXI interrupt request is generated In the RXI interrupt handling stores the RDR register value in the receive buffer When a reception error occurs an ERI interrupt request is generated In the ERI interrupt handling sets the error flag variable and dummy reads the RDR register Sets the RE bit to 0 and clears the error flags in the SSR register Sets the RIE bit to 0 the receive busy flag to 0 and calls the callback function SCI reception error 4 Completing the reception When the last data has been received in the RXI interrupt handling sets the RE bit to 0 serial reception is disabled and RIE bit to 0 RXI and ERI interrupt requests are disabled Sets the receive busy flag to 0 and calls the callback function SCI receive end Reception busy flag SCR RIE bit SCR RE bit Sets to 1b i 1 Sets to 1 by a program Sets to 0 by a program U IEN bit for the RXI interrupt i i Becomes 0 by an interrupt acceptance U DH U IR flag for the RXI interrupt RXD pin mode control bit PMR register 1 0 1 0 1 0 1 0 1 0 1 0 General input port RXD input Receive data 1 The bit specified depends on the SCI channel sele
31. elect bit RXD5 TXD5 Table 5 9 Constants Used in the Sample Code when SELECT_SCI6 is Selected in sci_cfg h Constant Name SCln Setting Value SCI6 Contents SCI channel SCI6 MSTP_SClIn MSTP SCI6 SCI6 module stop setting bit IPR_SClIn IPR SCI6 SCI6 interrupt priority level setting bit IR_SCIn_ERIn IR SCI6 ERI6 SCI6 ERI6 interrupt status flag IR_SCIn_RXIn IR SCI6 RXI6 SCI6 RXI6 interrupt status flag IR_SCIn_TXIn IR SCI6 TXI6 SCI6 TXI6 interrupt status flag IR_SCIn_TEIn IR SCI6 TEI6 SCI6 TEI6 interrupt status flag IEN_SCiIn_ERIn IEN SCI6 ERI6 SCI6 ERI6 interrupt request enable bit IEN_SCIn_RXiIn IEN SCI6 RXI6 SCI6 RXI6 interrupt request enable bit IEN_SCIn_TXIn IEN SCI6 TXI6 SCI6 TXI6 interrupt request enable bit IEN_SCIn_TEIn IEN SCI6 TEI6 SCI6 TEI6 interrupt request enable bit RXDn_PDR PORTB PDR BIT BO PBO I O select bit RXDn_PMR PORTB PMR BIT BO PBO pin mode control bit RXDnPFS PBOPFS PBO pin function control register TXDn_PODR PORTB PODR BIT B1 D I output data store bit TXDn_PDR PORTB PDR BIT B1 D I I O select bit TXDn_PMR PORTB PMR BIT B1 PB1 pin mode control bit TXDnPFS PB1PFS PB1 pin function control register PSEL_SETTING RO1AN1423EJ0101 July 1 2014 OBh Rev 1 01 Setting value of the pin function select bit RXD6 TXD6
32. eripheral_init void Initializes peripheral functions used None None Page 18 of 36 RENESAS RX210 RX21A and RX220 Groups Ch sc D end Outline Header Declaration Description Arguments Return Value cb_sci_rx_end Outline Header Declaration Description Arguments Return Value cb_sci_rx_error Outline Header Declaration Description Arguments Return Value Remarks SCL Init Outline Header Declaration Description Arguments Return Value SCI_StartReceive Outline Header Declaration Description Arguments Return Value Asynchronous Communication Using the SCI Callback function SCI transmit end None static void cb_sci_tx_end void This function is called when the SCI transmission has been completed None None Callback function SCI receive end None static void cb_sci_rx_end void This function is called when the SCI reception has been completed None None Callback function SCI receive error None static void cb_sci_rx_error void This function is called when the SCI receive error occurs None None Error processing is not performed in the sample code Add a program as required User interface function SCI initialization sci h void SCI_Init void Initializes the SCI None None User interface function SCI receive start sci h uint8_t SCl_StartReceive uint8_t pbuf uint8_t num CallBackFunc pcb_rx_end CallBackFunc pcb_rx_error Starts SCI reception uint8_t
33. essing for active peripheral functions after a reset R_INIT_StopModule Nonexistent port initialization R_INIT_NonExistentPort Clock initialization R_INIT_Clock Peripheral function initialization peripheral_init Enable maskable interrupts I flag 1 Initialize the RAM Sets 00h to the receive buffer User interface function SCI receive start SCI_StartReceive SCI reception being processed Has SCI reception started SCI reception started or an argument error occurred User interface function SCI transmit start SCI_StartTransmit SCI transmission being processed Has SCI transmission started SCI transmission started or an argument error occurred Figure 5 5 Main Processing RO1AN1423EJ0101 Rev 1 01 July 1 2014 RENESAS Page 22 of 36 RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 2 Port Initialization Figure 5 6 shows the Port Initialization Set port output data PORT1 PODR register B4 bit 1 LEDO Turned off B5 bit 1 LED1 Turned off B6 bit 1 LED2 Turned off Set port directions PORT1 PDR register B4 bit lt 1 LEDO Output B5 bit 1 LED1 Output B6 bit 1 LED2 Output PORT1 PMR register B4 bit lt 0 LEDO Uses pin as general I O port B5 bit lt 0 LED1 Uses pin as general I O port B6 bit lt 0 LED2 Uses pin as general I O port Set port modes Figure 5 6 Port Initialization 5 9 3 Peripheral Function Ini
34. from the information included herein Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such alteration modification copy or otherwise misappropriation of Renesas Electronics product Renesas Electronics products are classified according to the following two quality grades Standard and High Quality The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots etc High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems and safety equipment etc Renesas Electronics products are neither inten
35. he moment when power is supplied The states of internal circuits in the LSI are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied In a finished product where the reset signal is applied to the external reset pin the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed In a similar way the states of pins in a product that is reset by an on chip power on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified 3 Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited The reserved addresses are provided for the possible future expansion of functions Do not access these addresses the correct operation of LSI is not guaranteed if they are accessed 4 Clock Signals After applying a reset only release the reset line after the operating clock signal has become stable When switching the clock signal during program execution wait until the target clock signal has stabilized When the clock signal is generated with an external resonator or from an external oscillator during a reset ensure that the reset line is only released after full stabilization of the clock signal Moreover when switching to a clock signal produced with an external resonator or by an external oscillator while program execut
36. ion is in progress wait until the target clock signal is stable 5 Differences between Products Before changing from one product to another i e to a product with a different part number confirm that the change will not lead to problems The characteristics of an MPU or MCU in the same group but having a different part number may differ in terms of the internal memory capacity layout pattern and other factors which can affect the ranges of electrical characteristics such as characteristic values operating margins immunity to noise and amount of radiated noise When changing to a product with a different part number implement a system evaluation test for the given product Notice Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions
37. ive buffer main static uint8_t D but Transmit buffer main static sci_state_t sci_state SCI state cb_sci_rx_error static const uint8_t pbuf_tx Pointer to the transmit buffer SCI_StartTransmit static uint8_t tx_cnt Transmit counter SC Di Ier static uint8_t pbuf_rx Pointer to the reception buffer SCI_StartReceive static uint8_t rx_cnt Receive counter sci_rxi_isr SCI_StartReceive SCI_StartTransmit SCI_GetState sci_tei_isr sci_rxi_isr sci_eri_isr static sci_state_t SCI state RO1AN1423EJ0101 Rev 1 01 Page 16 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups 5 7 Functions Asynchronous Communication Using the SCI Table 5 14 lists the Functions Used in the Sample Code Table 5 14 Functions Used in the Sample Code Function Name Outline main Main processing port_init Port initialization R_INIT_StopModule R_INIT_NonExistentPort Stop processing for active peripheral functions after a reset Nonexistent port initialization R_INIT_Clock Clock initialization peripheral_init Peripheral function initialization cb_sci_tx_end cb_sci_rx_end Callback function SCI transmit end Callback function SCI receive end cb_sci_rx_error Callback function SCI receive error SCI_Init User interface function SCI initialization SCI_StartReceive SCI_StartTransmit User interface function SCI receive start User interface function S
38. le 5 6 Constants Used in the Sample Code when SELECT_SCIO is Selected in sci_cfg h d Constant Name SClin Setting Value SCIO Contents SCI channel SCIO MSTP_SCln MSTP SCIO SCIO module stop setting bit IPR_SClIn IPR SCIO SCIO interrupt priority level setting bit IR_SCIn_ERIn IR SCIO ERIO SCIO ERIO interrupt status flag IR_SCIn_RXiIn SCIO RXI0 interrupt status flag IR_SCIn_TXIn IR SCIO RXI0O IR SCIO TXIO SCI0 TXIO interrupt status flag IR_SCIn_TEIn IR SCI0 TEIO SCI0 TEIO interrupt status flag IEN_SCIn_ERIn IEN SCIO ERIO SCIO ERIO interrupt request enable bit IEN_SCIn_RXiIn SCIO RXI0 interrupt request enable bit IEN_SCIn_TXIn IEN SCIO RXI0 IEN SCIO TXI0 SCIO TXIO interrupt request enable bit IEN_SCIn_TEIn IEN SCI0 TEIO SCIO TEIO interrupt request enable bit RXDn PDR PORT2 PDR BIT B1 P21 I O select bit RXDn PMR PORT2 PMR BIT B1 P21 pin mode control bit RXDnPFS P21PFS P21 pin function control register TXDn_PODR PORT2 PODR BIT BO P20 output data store bit TXDn_PDR PORT2 PDR BIT BO P20 I O select bit TXDn_PMR PORT2 PMR BIT BO P20 pin mode control bit TXDnPFS P20PFS P20 pin function control register PSEL_SETTING Note OAh Setting value of the pin function select bit RXDO TXDO 1 SCIO is not available in 48 pin and 64 pin product
39. n and switches the output level on the TXD pin to high 2 a Starting a transmission Verifies the transmit busy flag B_TX BUSY using the user interface function SCI transmit start When the flag is 1 transmission busy SCT BUSY SCI transmission being processed is returned When the flag is 0 transmission ready sets the transmit busy flag to 1 the SCR TIE bit to 1 a TXI interrupt request is enabled and the SCR TE bit to 1 serial transmission is enabled When the TE bit is set to 1 the TXD pin becomes enabled Then sets the TXD pin mode control bit to 1 use pin as I O port for peripheral functions to switch the pin function to TXD output When the IEN bit for the TXI interrupt is set to 1 interrupt request is enabled the TXI interrupt request is generated e ES Transmitting data In the TXI interrupt handling the value in the transmit buffer is written to the TDR register When the last data is written sets the TIE bit to 0 a TXI interrupt request is disabled and the SCR TEIE bit to 1 a TEI interrupt request is enabled 4 KA Completing the transmission When the last data has been transmitted a TEI interrupt request is generated In the TEI interrupt handling sets the TXD pin mode control bit to 0 use pin as general I O port the TE bit to 0 serial transmission is disabled and the TEIE bit to 0 a TEI interrupt request is disabled Sets the transmit busy flag to 0 and calls the callback function
40. n this function refer to the Initial Setting application note for the product used R_INIT_NonExistentPort Outline Header Declaration Description Arguments Return Value Remarks R_INIT_Clock Outline Header Declaration Description Arguments Return Value Remarks peripheral_init Outline Header Declaration Description Arguments Return Value RO1AN1423EJ0101 Rev 1 01 July 1 2014 Nonexistent port initialization r_init_non_existent_port h void R_INIT_NonExistentPort void Initializes port direction registers for ports that do not exist in products with less than 100 pins None None The number of pins in the sample code is set for the 100 pin package PIN_SIZE 100 After this function is called when writing in byte units to the PDR registers or PODR registers which have nonexistent ports set the corresponding bits for nonexistent ports as follows set the I O select bits in the PDR registers to 1 and set the output data store bits in the PODR registers to 0 For details on this function refer to the Initial Setting application note for the product used Clock initialization r_init_clock h void R_INIT_Clock void Initializes the clock None None The sample code selects processing which uses PLL as the system clock without using the sub clock For details on this function refer to the Initial Setting application note for the product used Peripheral function initialization None static void p
41. o the PFSWE bit zi MPC PWPR register Enable writing to the PFS register PFSWE bit 1 MPC P20PFS register OAh PSEL 3 0 bits 1010b TXDO MPC P21PFS register 0Ah PSEL 3 0 bits 1010b RXDO Select pin functions ge MPC PWPR register Disabl ting to the PFS t isable writing to the register PFSWE bit lt 0 MPC PWPR register Disable writing to the PFSWE bit BOWI bit 1 PORT2 PMR register UI Set the port m de B1 bit lt 1 Uses the pin as UO port for peripheral function The I O register described here is the register used when SCI channel 0 is selected SClIn SCIO The I O registers specified depend on the SCI channel selected in the configuration file The setting value described here is the value when SCI channel 0 is selected The setting values specified depend on the SCI channel selected in the configuration file After writing values to bits RE TE RIE and TIE read these bits to confirm that the written values can be read Figure 5 11 User Interface Function SCI Initialization 1 2 RO1AN1423EJ0101 Rev 1 01 Page 25 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI Select the clock SClIn SCR register CKE 1 0 bits 00b On chip baud rate generator SCln SMR register lt 08h CKS 1 0 bits 00b PCLK clock MP bit 0 Multi processor communications function is disabled STOP bit 1 2 stop bits PE bit 0 Parity bit
42. on Description Arguments Return Value Asynchronous Communication Using the SCI Receive data full interrupt None static void sci_rxi_isr void This function is called in the SCI RXI interrupt handling Stores the receive data After receiving the last data disables the serial reception and calls the callback function SCI receive end None None Receive error interrupt None static void sci_eri_isr void This function is called in the SCI ERI interrupt handling Disables the serial reception and calls the callback function SCI receive error None None SCI ERI interrupt handling None static void Excep_SCIn_ERI n void Performs processing for the receive error interrupt None None SCI RXI interrupt handling None static void Excep_SClIn_RXIn void Performs processing for the reception data full interrupt None None SCI TXI interrupt handling None static void Excep_SCIn_TXIn void Performs processing for the transmit data empty interrupt None None SCI TEI interrupt handling None static void Excep_SCIn_TEIn void Performs processing for the transmit end interrupt None None RO1AN1423EJ0101 Rev 1 01 July 1 2014 Page 21 of 36 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 Flowcharts 5 9 1 Main Processing Figure 5 5 shows the Main Processing Disable maskable interrupts flag lt 0 Port initialization port_init Stop proc
43. pin mode control bit TXDnPFS PE1PFS PE1 pin function control register PSEL_SETTING OCh R01AN1423EJ0101 Rev 1 01 July 1 2014 Setting value of the pin function select bit RXD12 TXD12 Page 15 of 36 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 5 Structure Union List Figure 5 4 shows the Structure Union Used in the Sample Code pragma bit order left Bit field order The bit field members are allocated from upper bits pragma unpack The boundary alignment value for structure members Alignment by member type typedef union uint8_t byte struct uint8_t b tx_busy 1 Transmit busy flag 0 Transmission ready 1 Transmission busy uint8_t b_rx_busy 1 Receive busy flag 0 Reception ready 1 Reception busy uint8_t b_rx_orer 1 Overrun error flag 0 Overrun error not occurred 1 Overrun error occurred uint8_t b_rx_fer 1 Framing error flag 0 Framing error not occurred 1 Framing error occurred uint8_t A Not used bit sci_state_t pragma packoption End of specification for the boundary alignment value for structure members pragma bit_order End of specification for the bit field order Figure 5 4 Structure Union Used in the Sample Code 5 6 Variables Table 5 13 lists the static Variables Table 5 13 static Variables Variable Name Contents Function Used static uint8_t rx_buf BUF_SIZE Rece
44. re not available Use GC SCI5 SCI6 SC18 or SCI9 When using the RX220 Group SCIO SCI8 and SC112 are not available Use SCI1 SCI5 SCI6 or SCI9 R01AN1423EJ0101 Rev 1 01 Page 35 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 7 Sample Code Sample code can be downloaded from the Renesas Electronics website 8 Reference Documents User s Manual Hardware RX210 Group User s Manual Hardware Rev 1 50 RO1UH0037EJ RX21A Group User s Manual Hardware Rev 1 00 RO1UH0251EJ RX220 Group User s Manual Hardware Rev 1 10 RO1UH0292EJ The latest versions can be downloaded from the Renesas Electronics website Technical Update Technical News The latest information can be downloaded from the Renesas Electronics website User s Manual Development Tools RX Family C C Compiler Package V 1 01 User s Manual Rev 1 00 R20UT0570EJ The latest version can be downloaded from the Renesas Electronics website Website and Support Renesas Electronics website http www renesas com Inquiries http www renesas com contact RO1AN1423EJ0101 Rev 1 01 Page 36 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Application Note BEVISION HISTORY Asynchronous Communication Using the SCI Description Summary Date July 1 2013 First edition issued July 1 2014 Products Added the RX21A and RX220 Groups 3 Reference Application Notes Added the Ini
45. s Table 5 7 Constants Used in the Sample Code when SELECT_SCI1 is Selected in sci_cfg h Constant Name SClIn Setting Value SCH Contents SCI channel SCI1 MSTP_SClIn MSTP SCI1 SCI1 module stop setting bit IPR_SClIn IPR SCI1 SCI1 interrupt priority level setting bit IR_SCIn_ERIn IR SCI1 ERI1 SCI1 ERI1 interrupt status flag IR_SCIn_RXIn SCI1 RXI1 interrupt status flag IR_SCIn_TXIn IR SCI1 RXI1 IR SCI1 TXI1 SCI1 TXI1 interrupt status flag IR_SCIn_TEIn IR SCI1 TEI SCI1 TEI1 interrupt status flag IEN_SCIn_ERIn IEN SCI1 ERI1 SCI1 ERI1 interrupt request enable bit IEN_SCIn_RXiIn SCI1 RXI1 interrupt request enable bit IEN_SCIn_TXIn IEN SCI1 RXI1 IEN SCI1 TX11 SCI1 TXI1 interrupt request enable bit IEN_SCin_TEIn IEN SCI1 TEI1 SCI1 TEI interrupt request enable bit RXDn_PDR PORT1 PDR BIT B5 P15 I O select bit RXDn_PMR PORT1 PMR BIT B5 P15 pin mode control bit RXDnPFS P15PFS P15 pin function control register TXDn_PODR PORT1 PODR BIT B6 P16 output data store bit TXDn_PDR PORT1 PDR BIT B6 P16 I O select bit TXDn_PMR PORT1 PMR BIT B6 P16 pin mode control bit TXDnPFS P16PFS P16 pin function control register PSEL_SETTING RO1AN1423EJ0101 July 1 2014 OAh Rev 1 01 Setting value of the pin function select bit RXD1 TXD1 Page 12 of 36
46. t is disabled 1 A TEI interrupt request is enabled Reads the SCIn SSR register TEND flag 0 A character is being transmitted 1 Character transfer has been completed Interrupt not requested Transmit end interrupt sci_tei_isr IR flag 0 No interrupt request is generated 1 Interrupt request is generated Verify the IR flag Reads the IR217 register Note 1 The I O register described here is the register used when SCI channel 0 is selected SCIn SCIO The I O register read depends on the SCI channel selected in the configuration file Figure 5 23 SCI TEI Interrupt Handling RO1AN1423EJ0101 Rev 1 01 Page 34 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 6 Applying This Application Note to the RX21A or RX220 Group The sample code accompanying this application note has been confirmed to operate with the RX210 Group To make the sample code operate with the RX21A or RX220 Group use this application note in conjunction with the Initial Setting application note for each group For details on using this application note with the RX21A and RX220 Groups refer to 5 Applying the RX210 Group Application Note to the RX21A Group in the RX21A Group Initial Setting application note and 4 Applying the RX210 Group Application Note to the RX220 Group in the RX220 Group Initial Setting application note Note When using the RX21A Group SCIO and SCI12 a
47. the military including but not limited to the development of weapons of mass destruction When exporting the Renesas Electronics products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations 10 Itis the responsibility of the buyer or distributor of Renesas Electronics products who distributes disposes of or otherwise places the product with a third party to notify such third party in advance of the contents and conditions set forth in this document Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products 11 This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics 12 Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics SALES OFFICES Renesas Electronics Corporation http www renesas com RENESAS Rel er to http
48. tial Setting application notes for the RX21A and RX220 Groups Modified the description of reference application note in the following functions R_INIT_StopModule R_INIT_NonExistentPort and R_INIT_Clock 6 Applying This Application Note to the RX21A or RX220 Group Added 8 Reference Documents Added the User s Manual Hardware for the RX21A and RX220 Groups All trademarks and registered trademarks are the property of their respective owners A 1 General Precautions in the Handling of MPU MCU Products The following usage notes are applicable to all MPU MCU products from Renesas For detailed usage notes on the products covered by this document refer to the relevant sections of the document as well as any technical updates that have been issued for the products 1 Handling of Unused Pins Handle unused pins in accordance with the directions given under Handling of Unused Pins in the manual The input pins of CMOS products are generally in the high impedance state In operation with an unused pin in the open circuit state extra electromagnetic noise is induced in the vicinity of LSI an associated shoot through current flows internally and malfunctions occur due to the false recognition of the pin state as an input signal become possible Unused pins should be handled as described under Handling of Unused Pins in the manual 2 Processing at Power on The state of the product is undefined at t
49. tialization Figure 5 7 shows the Peripheral Function Initialization peripheral_init User interface function SCI initialization SCI_Init Figure 5 7 Peripheral Function Initialization 5 9 4 Callback Function SCI Transmit End Figure 5 8 shows the Callback Function SCI Transmit End PORT1 PODR register Turn on LEDO B4 bit lt 0 return Figure 5 8 Callback Function SCI Transmit End RO1AN1423EJ0101 Rev 1 01 Page 23 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 5 Callback Function SCI Receive End Figure 5 9 shows the Callback Function SCI Receive End PORT1 PODR register Turn on LED1 B5 bit lt 0 return Figure 5 9 Callback Function SCI Receive End 5 9 6 Callback Function SCI Receive Error Figure 5 10 shows the Callback Function SCI Receive Error PORT1 PODR register Turn on LED2 B6 bit lt 0 User interface function SCI state obtain SCI_GetState Has an overrun error occurred Has a framing error occurred Processing when an overrun error occurs Processing when a framing error occurs return Note 1 Error processing is not performed in the sample code Add a program as required Figure 5 10 Callback Function SCI Receive Error RO1AN1423EJ0101 Rev 1 01 Page 24 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI 5 9 7 User Interface F
50. unction SCI Initialization Figure 5 11 and Figure 5 12 show the User Interface Function SCI Initialization SCH Int IERT A register 1 IEN6 bit lt 0 SCIO ERIO interrupt request is disabled IEN7 bit lt 0 SCIO RXIO interrupt request is disabled IER1B register IENO bit lt 0 SCIO TXIO interrupt request is disabled IEN1 bit lt 0 SCIO TEIO interrupt request is disabled PRCR register A502h PRC1 bit 1 Enables writing to registers related to the operation MSTPCRB register MSTPB31 bit lt 0 The module stop state is canceled for the SCIO module PRCR register A500h PRC1 bit 0 Disables writing to registers related to the operation Disable the SCln interrupt request Cancel the module stop state Disable transmission reception and SClIn SCR register lt 00h disable interrupt requests 3 TEIE bit 0 A TEI interrupt request is disabled RE bit 0 Serial reception is disabled TE bit 0 Serial transmission is disabled RIE bit 0 RXI and ERI interrupt requests are disabled TIE bit 0 A TXI interrupt request is disabled PORT2 PODR register 1 SEENEN BO bit lt 1 TXDO High level PORT2 PDR register BO bit lt 1 TXDO Output B1 bit lt 0 RXDO Input PORT2 PMR register BO bit lt 0 Uses the TXDO pin as general I O port B1 bit lt 0 Uses the RXDO pin as general I O port MPC PWPR register BOWI bit 0 Set port directions Set port modes Enable writing t
51. v tENE SAS APPLICATION NOTE RO1AN1423EJ0101 RX210 RX21A and RX220 Groups Rev 1 01 Asynchronous Communication Using the SCI A wees Abstract This document describes the method to perform asynchronous serial transmission and reception using the serial communication interface SCI in the RX210 RX21A and RX220 Groups Products RX210 RX21A and RX220 Groups When using this application note with other Renesas MCUs careful evaluation is recommended after making modifications to comply with the alternate MCU ROIAN1423EJ0101 Rev 1 01 Page 4 of 36 July 1 2014 RENESAS RX210 RX21A and RX220 Groups Asynchronous Communication Using the SCI Contents Ne ee Te E 3 2 Operation Confirmation Conditions cccccccececeeeeeccee cece eeeececcaeceeeeeeeaaecaeeeeeeesesscnieeeeeeeessnsisaeeees 4 3 Reference Application Note A 4 4 WAR TE 5 AA PINS USCGsctasaiscissatcaceaseadarectadectaagadlaarehldetaa sad dacaehthvensavatdadense otaaaeaddonaiadouassadatansd aeaa 5 e Oe ul LE 6 5 1 Operation Overview eee 7 5 1 1 Serial TrAMSMISSION io EE 7 5 1 2 Serial Reception 20 eee e ee ccecee cece cece eee ee cece cece cece ea ae eee ee eee ace aaaeceeeeeeesecaeaeeeeeeseeeeeeuceeeeeeeeeeeeea 8 5 2 IER te 9 2 9 Option setting Memos enrera e e SES theta Ee 9 e EN e TE 10 5 9 Structure UMIOM LISt EE 16 56 VatableS sandro aiies asean anahe iaaa Aea geed dee du degen de eege 16 5 7 Die Le EE 17 58 Function SPeCIICALIONS ET 17 e
Download Pdf Manuals
Related Search
Related Contents
Copyright © All rights reserved.
Failed to retrieve file