此为dontium小组DIY进展:
https://bbs.eeworld.com.cn/thread-311388-1-1.html希望有TI F28035编程经验、有一定时间和精力、并乐于分享的朋友加入!如果有兴趣,可以跟帖说明,并通过站内短消息给soso,告知QQ号码。
期待DIY电源开源设计小组,有你的加入。
恩,排队等
http://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
F28035是用C28系列CPU,2810也是,编程是一样的
DIY电源 需要大家的共同参与、贡献, 单凭几个人的力量毕竟是有限的
力量不在多少,只要尽力就好
其实我是很想参加啦;不过怕耽误大家的进度。
要不我贴一下我毕业设计的代码吧;要是大家觉得还可以的话,那希望能出一份力
这是我2011年毕业那时写的,主要功能就是控制两个电机移动到指定的位置;通过AD采样获取移动的位置
下面是那时写的main文件,其他详见附件 (ccs3.3的)
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
#include "stdio.h"
#include"motor.h"
// Prototype statements for functions found within this file.
#define SETGPIOA5 GpioDataRegs.GPASET.bit.GPIOA5=1;
#define RESETGPIOA5 GpioDataRegs.GPACLEAR.bit.GPIOA5=1;
// Global variable for this example
// These are defined by the linker (see F2810.cmd)
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadEnd;
extern Uint16 RamfuncsRunStart;
Uint32 ErrorCount;
Uint32 MessageReceivedCount;
Uint32 TestMbox1 = 0;
Uint32 TestMbox2 = 0;
Uint32 TestMbox3 = 0;
#define none 0xaa
void main(void)
{
int temp=0;
unsigned char mode=none;
unsigned char modebuf=none;
unsigned char execute=0;
unsigned char string[]={"asdfghjkl0"};
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
InitSysCtrl();
//这里为什么SYSCLKOUT/6 没有弄明白
// For this example, set HSPCLK to SYSCLKOUT / 6 (25Mhz assuming 150Mhz SYSCLKOUT)
EALLOW;
SysCtrlRegs.HISPCP.all = 0x3; // HSPCLK = SYSCLKOUT/6
EDIS;
// Step 2. Initalize GPIO:
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP281x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
InitPieVectTable();
// symbols are created by the linker. Refer to the F2812.cmd file.
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
InitFlash();
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
InitSci(); // Init SCI-A
InitAdc();
Configure();
InitECan(); // Initialize the eCAN module
configureECan();
init_eva(); //时间A初始化
// Step 5. User specific code, enable interrupts:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
//Osea Add: Add user code here
//sendbitflage=1;
// SciaRegs.SCITXBUF='B';
mode=0;
// Step 6. IDLE loop. Just sit and loop forever (optional):
while(1)
{
// ECanaRegs.CANTRS.all = 0x00000001<<7; // Set TRS for all transmit mailboxes
// while(ECanaRegs.CANTA.bit.TA7== 0 ) {} // Wait for all TAn bits to be set..
// ECanaRegs.CANTA.bit.TA7=1; // Clear all TAn
if(0==GetStateBotton){mode=5;}
else if(0==GetStateForward){mode=6;}
else if(0==GetStateBackward){mode=7;}
else if(0==GetStateSpeedLeve_1) {mode=1; Gears(1);}
else if(0==GetStateSpeedLeve_2) {mode=2; Gears(2);}
else if(0==GetStateSpeedLeve_3) {mode=3; Gears(3);}
else if(0==GetStateSpeedLeve_4) {mode=4; Gears(4);}
else {mode=0;Gears(0);}
DSP28x_usDelay(1000);
if(mode!=modebuf){modebuf=mode;execute=1;}
switch(mode)
{
case 0: ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7;//0
ECanaMboxes.MBOX7.MDH.all = 0x00000000;
break;
case 1: ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7;
ECanaMboxes.MBOX7.MDH.all = 0x00000001;
break;
case 2: ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7;
ECanaMboxes.MBOX7.MDH.all = 0x00000002;
break;
case 3: ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7;
ECanaMboxes.MBOX7.MDH.all = 0x00000003;
break;
case 4: ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7;//4
ECanaMboxes.MBOX7.MDH.all = 0x00000004;
break;
case 5: ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7;//前进
ECanaMboxes.MBOX7.MDH.all = 0x00000005;
break;
case 6: ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7;//后退
ECanaMboxes.MBOX7.MDH.all = 0x00000006;
break;
case 7: ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7;//按钮
ECanaMboxes.MBOX7.MDH.all = 0x00000007;
break;
default:;
}
if(execute==1)
{
ECanaRegs.CANTRS.all = 0x00000001<<7; // Set TRS for all transmit mailboxes
ECanaRegs.CANTA.bit.TA7== 0 ) {} // Wait for all TAn bits to be set..
ECanaRegs.CANTA.bit.TA7=1; // Clear all TAn
execute=0;
}
}
}
//===========================================================================
// No more.
//===========================================================================
[ 本帖最后由 lindabell 于 2012-2-8 10:01 编辑 ]
围观
生活就是油盐酱醋再加一点糖,快活就是一天到晚乐呵呵的忙
===================================
做一个简单的人,踏实而务实,不沉溺幻想,不庸人自扰