Renesas Single-Chip Microcomputer M38C89T-ADF Bedienungsanleitung Seite 120

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 138
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 119
4BUsage Examples
5.3 23BBus Controller
5
5-4
Rev.1.00 May 22 2012
REJ09B0566
5.2. I/O Port
Figure 5-2 shows examples of I/O port configuration, reading and writing.
/* PDL functions */
#include "r_pdl_io_port_library_SH7267.h"
/* Following header file provides access to intrinsic functions useful for
Configuring and controlling the interrupts. */
#include <machine.h>
/* PDL device-specific definitions */
#include "r_pdl_definitions.h"
void io_handler(void);
void IOPort_Test(void)
{
uint16_t data = 0u;
uint16_t index = 0u;
uint16_t index1 = 0u;
uint8_t direction = 0u;
uint8_t buffer = 0u;
uint8_t pull_up = 0u;
uint16_t output = 0u;
R_IO_PORT_Set(PDL_IO_PORT_J_6, PDL_IO_PORT_OUTPUT, 0);
R_IO_PORT_Set(PDL_IO_PORT_J_7, PDL_IO_PORT_OUTPUT, 0);
/* Toggle LED 1 */
for(index1 = 0; index1 < 10; index1++)
{
_check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_HIGH);
for (index = 0; index < 0xFFFF;index++)
{
nop();
}
_check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_LOW);
}
/* configure PORT J as input */
R_IO_PORT_Write(PDL_IO_PORT_J,0x0000);
/* Set the lower 8 bits on port PJ to output */
R_IO_PORT_Modify(PDL_IO_PORT_J,PDL_IO_PORT_OR,0x00FF);
/* wait for the PORT J to be high */
R_IO_PORT_Compare(PDL_IO_PORT_J_7, 0x0080, io_handler);
/* make the port PJ6 to be low */
_check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_LOW);
/* Read to verify the Port PJ6 */
R_IO_PORT_Read(PDL_IO_PORT_J_6, &data);
/* make the port PJ6 to be high */
_check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_HIGH);
/* Read to verify the Port PJ6 */
R_IO_PORT_Read(PDL_IO_PORT_J_6, &data);
}
void io_handler(void)
{
/* make port low */
_check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_LOW);
}
Seitenansicht 119
1 2 ... 115 116 117 118 119 120 121 122 123 124 125 ... 137 138

Kommentare zu diesen Handbüchern

Keine Kommentare