English
Language : 

SH7047F Datasheet, PDF (78/85 Pages) Renesas Technology Corp – Renesas 32-Bit RISC Microcomputer SuperH RISC engine Family/SH7047 Series
5.8 Reception Program Listing
/********************************************************************************/
/*
HCAN-2 Reception Program (Example 5)
*/
/********************************************************************************/
#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_IRR2(void);
/********************************************************************************/
/*
Main routine
*/
/********************************************************************************/
void r_main(void){
unsigned short *work;
/* Clear bit MCR0 */
HCAN_MCR = 0x0000;
/* Clear reset request bit */
/* Set local acceptance filter */
HCAN_MB1.LAFM15 = 0x0000;
/* Set identifier filter mask for mailbox 1 */
/* Clear bit IRR0 */
HCAN_IRR = 0x0001;
/* Clear reset interrupt flag (to clear, write 1) */
/* Set pins */
PB.PBCR1 = 0x0000;
/* Set PB HCAN-2 */
PB.PBCR2 = 0x000F;
/* Set PB HCAN-2 */
/* Set bit rate (BCR): bit rate is 250 kbps when φ = 50 MHz */
HCAN_BCR0 = 0x0009;
/* BRP=9(10 system clock) */
HCAN_BCR1 = 0x4300;
/* TSEG1=4(5tq),TSEG2=3(4tq) */
/* Initialize mailbox */
work = (unsigned short *)0xFFFFB100;
do {
*work = 0xFFFF;
work++;
} while(work < (unsigned short *)0xFFFFB4F4);
/* Set MBC */
HCAN_MB1.MC4 = 0x11;
/* Set mailbox 1 to use ATX, enable
remote frame reception, and enable data frame transmission */
/* Set remote request interrupt */
HCAN_IMR = 0xFFFB;
/* Enable remote request interrupts */
HCAN_MBIMR0 = 0xFFFD;
/* Enable mailbox 1 interrupt requests */
INTC.IPRK = 0x00F0;
/* Set RM1 priority */
/* Set transmission data */
HCAN_MB1.MC0 = 0x5550;
/* Select data frame and standard format,
set identifier */
HCAN_MB1.MC5 = 0x08;
/* Set data length: 8 bytes */
HCAN_MB1.MD7 = 0x55;
/* Set transmission data: 01010101 */
HCAN_MB1.MD8 = 0x66;
/* Set transmission data: 01100110 */
Rev. 1.00, 08/03, page 70 of 74