?? dma.c
字號:
/*********************************************************************/
/* FILE NAME : rjj05b0218_src.c */
/* Ver : 1.10 */
/* CPU : M16C/62 */
/* FUNCTION : The DMA setting procedure in the C language. */
/*-------------------------------------------------------------------*/
/* Copyright(C)2003, Renesas Technology Corp. */
/* Copyright(C)2003, Renesas Solutions Corp. */
/* All rights reserved. */
/* */
/*********************************************************************/
/****************************************/
/* include file */
/****************************************/
#include "sfr62P.h" // Special Function Register Header File
/****************************************/
/* Function declaration */
/****************************************/
void ta1_init(void);
void dma0_int(void);
/****************************************/
/* Global variable declaration */
/****************************************/
static char data0[] = {0x1,0x3,0x7,0xf,0x1f,0x3f,0x7f,0xff};
/****************************************/
/* main function */
/****************************************/
void main(void)
{
pd0 = 0xff; // P0 is an output port.
pd6 = 0xff; // P6 is an output port.
pd8 = 0x1f; // P8_0-P8_4 output
p0 = 0; //
p6 = 0; //
p8 = 0; //
ta1_init(); //
dm0sl = 0x03; // (1) A setup of DM0SL(TA1)
dm0con = 0x13; // (2) A setup of DM0CON
// DMA0 inhibit,8bit,repeat,fixed->forward)
// (3) A setup of SAR0(DMA0 source pointer)
sar0_addr.byte.low = (char)(&data0);
sar0_addr.byte.mid = (char)((unsigned long)(&data0) >> 8);
sar0_addr.byte.high = (char)((unsigned long)(&data0) >> 16);
// (4) A setup of DAR0(DMA0 destination pointer)
dar0_addr.byte.low = (char)(&p0);
dar0_addr.byte.mid = (char)((unsigned long)(&p0) >> 8);
dar0_addr.byte.high = (char)((unsigned long)(&p0) >> 16);
tcr0 = 0x07; // (5) A setup of TCR0(DMA0 transfer count)
dm0ic = 0x04; // (6) A setup of DM0IC(DMA0 interrupt control register)
dm0con = 0x1B; // (7) A setup of DM0CON
// DMA0 permission,8bit,repeat,fixed->forward)
asm("fset I"); // (8) Interruption permission.
tabsr = 0x02; // (9) Operation of the circumference function of a DMA demand factor is permitted.
while(1)
{
p8_1 = !p8_1; // test end.
}
}
/****************************************/
/* Timer-A1 initialization */
/****************************************/
void ta1_init(void)
{
ta1mr = 0x80; // Timer-mode(f32)
ta1 = 0x8fff; // Timer value setup
}
/****************************************/
/* DMA0 interrupt routine */
/****************************************/
#pragma INTERRUPT/B dma0_int
void dma0_int(void)
{
p6_0 = !p6_0; //
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -