Renesas Single-Chip Microcomputer M38C89T-ADF Uživatelský manuál Strana 134

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 138
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 133
4BUsage Examples
5.7 Serial Communication Interface
5
5-18
Rev.1.00 May 22 2012
REJ09B0566
(2) SCI Transmission
Figure 5-9 shows the configuration of SCI channels 0 and 1 and the transmission of data (on channel 0) using polling and then
interrupts.
/* Peripheral driver function prototypes */
#include r_pdl_sci.h
#include r_pdl_cpg.h
#include r_pdl_intc.h
/* PDL device-specific definitions */
#include r_pdl_definitions.h
/* Callback function prototype */
void SCI3TxFunc(void);
volatile char result[2];
void main(void)
{
/* Put a null at the end */
result[1] = 0;
/* Initialise the system clocks */
R_CPG_Set(18E6, 144E6, 36E6, PDL_CPG_CK_2, PDL_CPG_OUT_CK_01);
/* Set the CPUs Interrupt Priority Level to 0 */
R_INTC_Write(
PDL_INTC_REG_IPR,
0,
0
);
/* configure SCIF_3 in asynchronous serial Mode. Configured it as a transmitter with
BAUD rate of 19200, 8 bit data, no parity and 1 stop bit */
R_SCI_Create(3,
PDL_SCI_ASYNC | PDL_SCI_TX_CONNECTED |
PDL_SCI_8_BIT_LENGTH ,
19200,3,0);
/* configure SCIF_0 in asynchronous serial Mode. Configured it as a receiver with
BAUD rate of 19200, 8 bit data, no parity and 1 stop bit */
R_SCI_Create(1,
PDL_SCI_ASYNC | PDL_SCI_RX_CONNECTED |
PDL_SCI_8_BIT_LENGTH ,
19200,3,0);
/* Wait for 1 character to be received on channel 1 */
R_SCI_Receive(
1,
result,
1,
PDL_NO_FUNC,
PDL_NO_FUNC,
PDL_NO_FUNC
);
/* Send a string on channel 3 (wait for completion) */
R_SCI_Send(
3,
Renesas SH7267,
PDL_SCI_IDLE,
PDL_NO_FUNC
);
/* Send another string on channel 3 */
R_SCI_Send(
0,
Zobrazit stránku 133
1 2 ... 129 130 131 132 133 134 135 136 137 138

Komentáře k této Příručce

Žádné komentáře