English
Language : 

SH7047F Datasheet, PDF (60/85 Pages) Renesas Technology Corp – Renesas 32-Bit RISC Microcomputer SuperH RISC engine Family/SH7047 Series
4.8 Reception Program Listing
/********************************************************************************/
/*
HCAN-2 Reception Program (Example 4)
*/
/********************************************************************************/
#include <stdio.h>
/* Library function header file */
#include <machine.h>
/* Library function header file */
#include "SH7047.h"
/* Peripheral register definition header file */
/********************************************************************************/
/*
Function prototype declarations
*/
/********************************************************************************/
void r_main(void );
void RM1_IRR1(void);
/********************************************************************************/
/*
Define constants
*/
/********************************************************************************/
#define DTMR (*(unsigned short *)0xFFFFD080) /* DTC register data */
#define DTCRA (*(unsigned short *)0xFFFFD082) /* DTC register data */
#define DTCRB (*(unsigned short *)0xFFFFD086) /* DTC register data */
#define DTSAR (*(unsigned long *)0xFFFFD088) /* DTC register data */
#define DTDAR (*(unsigned long *)0xFFFFD08C) /* DTC register data */
#define MBbuff (*(unsigned char *)0xFFFFD100) /* Storage area for received data */
/********************************************************************************/
/*
Main routine
*/
/********************************************************************************/
void r_main(void){
unsigned short *work;
/* Initialize storage area for received data */
work = (unsigned short *)0xFFFFD100;
do {
*work = 0x0000;
work++;
} while(work < (unsigned short *)0xFFFFD180);
/* DTC settings */
DTMR = 0xA890;
/* Increment both DTSAR and DTDAR
after transfer completes, set block transfer mode and byte transfer */
DTSAR = (unsigned long)&HCAN_MB0.MD7; /* Set transfer source address */
DTDAR = (unsigned long)&MBbuff;
/* Set transfer destination address */
DTCRA = 0x000F;
/* Block transfer: 15 blocks */
DTCRB = 0x0008;
/* Block length: 8 bytes */
DTC.DTBR = 0xFFFF;
/* Register data base address */
DTC.DTEF |= 0x04;
/* HCAN-2 interrupt (RM1) */
/* Clear bit MCR0 */
HCAN_MCR = 0x0000;
/* Clear reset request bit */
/* Set local acceptance filter */
HCAN_MB0.LAFM15 = 0x7FF0;
/* Set identifier filter mask for mailbox 0 */
/* Clear bit IRR0 */
HCAN_IRR = 0x0001;
/* Clear reset interrupt flag (to clear, write 1) */
/* Set pins */
Rev. 1.00, 08/03, page 52 of 74