📄 c6713test.c
字号:
/*
* Copyright 2007 by WXK
*
*/
/**************************************************************************/
/* */
/* c6713test . C */
/* */
/* Basic C standard I/O from main. */
/* */
/* */
/***************************************************************************/
#include "math.h"
#include "c6713regs.h"
void sys_init();
void IO_test1();
void IO_test2();
void INT_test();
void SRAM_test();
void INSTRU_test();
void asmtest();
void other();
int Gpio_val,Gpio_tmp;
/*
* ======== main ========
*/
/* you can use intrinsics function that map directly to inlined C6713
*instruction,for detail,see TMS320C6000 Programmer's Guide
*for example
*int _abs(int);//map to assembly instruction ABS
*int b = _abs(-2);
*/
void main()
{
sys_init();
Gpio_val = GPVAL;
while(1)
{
Gpio_tmp = GPVAL;
if(Gpio_tmp&0x0000FFFF == 0x0000FFFF)
{
switch(Gpio_val&0x0000000E)
{
case 0x00000000:
IO_test1(); //IO Test 1
break;
case 0x00000002:
IO_test2(); //IO Test 2
break;
case 0x00000004:
INT_test(); //External Interrupt Test
break;
case 0x00000006:
SRAM_test(); //External SRAM Test
break;
case 0x00000008:
INSTRU_test(); //Instruction Set Test
break;
default:
other(); //return
}
}
else
asm(" nop 5 ");
}
}
void sys_init()
{
/* config the CSR,disables all interrupts,except the reset and NMI */
asm(" mvk 00000100h,a0 ");
asm(" mvc a0,CSR ");
/* config the AMR(addressing mode register) */
asm(" mvk 00000000h,a0 ");
asm(" mvc a0,AMR "); //all mode are linear modification
/* congig the interrupt Enable Register */
asm(" mvk 00000001h,a0 ");
asm(" mvc a0,IER "); //disable all nonreset interrupts
DEVCFG = 0x0000000F; //2 I2C + 2 McASP + GPIO
/* config the EMIF registers */
GBLCTL = 0x00003080; //clkout1 and clkout2 are held high,hold is disabled
CECTL1 = 0xFFFFFF13; //asynchronous 16-bit-wide interface
CECTL0 = 0xFFFFFF13; //asynchronous 16-bit-wide interface
EXTPOL = 0x00000000; //a low-to-high transition on an interrupt source is recognized as an interrupt
/* config the PLL registers */
PLLCSR = 0x00000009; //divider D0 and PLL are not bypassed
PLLM = 0x00000004; //*4
PLLDIV0 = 0x00008001; //divided by 2,dsp core is working at 40M
/* config the GPIO registers */
GPEN = 0x0000FFFF;
}
void IO_test1()
{
GPDIR = 0x000000FF; //GP0-7 are output,GP8-15 are input
while(1)
{
Gpio_val = GPVAL;
GPVAL = (Gpio_val&0x0000FF00)>>8;
}
}
void IO_test2()
{
GPDIR = 0x0000FF00; //GP0-7 are input,GP8-15 are output
while(1)
{
Gpio_val = GPVAL;
GPVAL = (Gpio_val&0x000000FF)<<8;
}
}
void INT_test()
{
/* config the CSR,enables all interrupts,except the reset and NMI */
asm(" mvk 00000101h,a0 ");
asm(" mvc a0,CSR ");
/* congig the interrupt Enable Register */
asm(" mvkl 0FFF3h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //enable all interrupts
GPDIR = 0x0000000F; //GP0-3 are output,GP4-15 are input
while(1)
{
asm(" nop 8 ");
}
}
void SRAM_test()
{
// short *a;
// a = &*((volatile int *)0x80000000);
}
void INSTRU_test()
{
GPDIR = 0x0000FFFF; //GP0-15 are output
asmtest();
}
void other()
{
asm(" nop 5 ");
}
void interrupt capNMI()
{
asm(" mvkl 0001h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //disable all interrupts
GPVAL = 0x00000001;
asm(" mvkl 0FFF3h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //enable all interrupts
}
void interrupt capint4()
{
asm(" mvkl 0001h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //disable all interrupts
GPVAL = 0x00000002;
asm(" mvkl 0FFF3h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //enable all interrupts
}
void interrupt capint5()
{
asm(" mvkl 0001h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //disable all interrupts
GPVAL = 0x00000003;
asm(" mvkl 0FFF3h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //enable all interrupts
}
void interrupt capint6()
{
asm(" mvkl 0001h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //disable all interrupts
GPVAL = 0x00000004;
asm(" mvkl 0FFF3h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //enable all interrupts
}
void interrupt capint7()
{
asm(" mvkl 0001h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //disable all interrupts
GPVAL = 0x00000005;
asm(" mvkl 0FFF3h,a0 ");
asm(" mvklh 0000h,a0 ");
asm(" mvc a0,IER "); //enable all interrupts
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -