ppa2001 发表于 2009-6-11 22:54:59

请教DX下,我用外部中断1.配置好后
我设置GPIO7为中断
在GPIO7中断产生后,我马上指派GPIO9为外部中断,这样可以吗?谢谢了~
程序大概如下:
开始:
EALLOW;
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL=7;      GPIO7为外部中断1
EDIS;
interrupt void cpu_GPIO_isr(void)             中断产生后马上设置GPIO9为中断1
{
...........

EALLOW;
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL=9;
EDIS;
}

mpuhome 发表于 2009-6-12 08:44:25

100楼,可以

ppa2001 发表于 2009-6-12 23:12:18

谢谢楼主了!

ppa2001 发表于 2009-6-14 19:04:58

还的请教LZ下
我现在做个程序,有外部中断,和定时期中断
大概是外步中断触发后,打开定时期,等定时器中断产生
其中我用了INITEN表示定时期运行完了。
interrupt void cpu_GPIO_isr(void)
{
    Uint32 bak;
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
        if(INITEN==1)                                    //使能
        {   
            INITEN=0;                                    //关闭
         ConfigCpuTimer0(12000);                     //开定时器//这函数是我编写的,可以运行
         StartCpuTimer0();                           //定时器0开始计数
         
        }
}

interrupt void cpu_timer0isr(void)
{
   INITEN=1;                            //打开
   StopCpuTimer0();

   CpuTimer0Regs.TCR.bit.TIF = 1;

   GpioDataRegs.GPATOGGLE.bit.GPIO23=1;

   
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}
现在的问题是,定时期中断只能在开始触发一次,然后就是INITEN=0; 导致定时期不运行了~
我怀疑是 外部中断的 PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; 把定时期中断给清除了,导致 INITEN=0;
请教DX,怎么解决这个问题哈?谢谢了哈

xyang18 发表于 2009-6-14 19:27:43

mpuhome你好
我这有一个dsp的仿真器ICETEK-5100USB V2.0 和 ICETEK F2407-A开发板,但是缺少这方面的资料,如果楼主有这方面资料还希望给我发一份,谢谢!
我的邮箱是xyang18@126.com

tiancaigao7 发表于 2009-6-15 08:05:49

应该不是这个方面的问题,毕竟你是先相应的中断,然后再开启的定时器,因此没有关系。看你的逻辑好像没有什么问题。你可以在定时器中断中设一个断点。看看。

ppa2001 发表于 2009-6-15 17:18:56

恩,我在检测下,现在就是INITEN 一开始等于1 ,然后就时钟是INITEN=0 了 。而且有时候感觉可以进定时器中断,有时候就不可以~

xiamo 发表于 2009-6-16 10:33:09

楼主你好,我在编译程序时出现的这样的错误 identifier "PieCtrl" is undefined   请问这是什么原因啊在主程序中PieCtrl()已经初始化过了,还需要在哪里定义吗?

ppa2001 发表于 2009-6-17 22:42:38

我回去试验了下,我发现了个奇怪的现象,我如果在定时器中断里加个断点,程序就对的,那怕我取消断点后,全速运行,程序也一直对的
但如果我重新加载运行没有设置断点,程序就可能不对,不产生定时期中断 大概30%概率出错,有时可能运行正常`,这算是BUG吗?
interrupt void cpu_timer0isr(void)
{
   INITEN=1;                            //打开
断点加这// StopCpuTimer0();

   CpuTimer0Regs.TCR.bit.TIF = 1;
   
   GpioDataRegs.GPATOGGLE.bit.GPIO23=1;
   
   
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

tiancaigao7 发表于 2009-6-18 08:28:18

有可能是流水线的问题,DSP经常会出现这样的奇怪问题,你可以尝试在定时器中断里面加几条空语句,或者nop这样的延时语句看看,如果是流水间的问题的话,一般就可以解决。

ppa2001 发表于 2009-6-18 17:24:48

好的 ,我试验下,谢谢了

ppa2001 发表于 2009-6-18 20:16:09

试验了,加了asm(" RPT #5 || NOP");
好像没什么效果,修改了下顺序,把CpuTimer0Regs.TCR.bit.TIF = 1;删除了 。
现在在调试模式下,都是OK,但把程序烧入FLASH中,上电在运行,一般第一次都不行,但复位下就可以了~晕
奇怪哈~郁闷~

ppa2001 发表于 2009-6-19 19:33:45

我最后使用了外部中断INT13,结果还是一样,会随即出现错误,晕~
对了,在请教下 ,INT13不属于复用中断,它是怎么清除中断标志位的,好像它会自动清除中断标示位?

问题解决了,我把中断使能函数,放在了定时期初始化函数的后面,就可以了,`以前放的比较靠前~没想这么多,学习了~

mpuhome 发表于 2009-6-20 10:00:56

这里越来越热闹了,大家继续盖高楼~
104楼,很抱歉,我没有你需要的资料,不过你既然有东西,应该可以找厂家要资料的

glbest 发表于 2009-6-23 00:04:11

请教楼主,我的SPI主机为什么会收到我发出去的数据,不是使用loop back模式

glbest 发表于 2009-6-23 12:29:57

看样子是从机的TXBUF的数据没有保持住,我只写了一次TXBUF,结果主机发送的内容放在从机的SPIDAT,从机又送出去,用过其他芯片,SPI从机的TXBUF内容只需写一次就行了,每次主机提供时钟,SPIDAT从TXBUF取数据才对!忘了我说,我用的是两台28335,SPI主从通信

mpuhome 发表于 2009-6-23 23:21:49

楼上用28335啊,现在还比较贵吧
114楼的问题,SPI主不要接任何设备,也就是SPI线悬空,看是否可以收到自己发的数据
115楼,我没用过2个CPU间做主从机,但是TXBUF只写一次就可以了

glbest 发表于 2009-6-24 21:52:06

spi主悬空收不到自已发的数据,从我的测试看,由于从机只写一次TXBUF,结果主机发送的数据存放在从机的SPIDATA寄存器,主机提供时钟的情况下,从机SPIDATA里的数据发回给了主机

ppa2001 发表于 2009-6-29 22:58:53

请教LZ下,我用外部中断,一开始设置为上升沿中断,然后在特定时期,在设置为下降沿产生中断,这样不断地改变中断条件,可以吗?
不使用上升压下降呀都产生中断,每次只用单个的条件~
谢谢了 ~

tiancaigao7 发表于 2009-6-30 07:49:22

当然可以了,只要你能正确地设定就是可以的。

ppa2001 发表于 2009-6-30 20:56:43

好的,谢谢了哈~

xyzyx 发表于 2009-7-21 16:58:00

请问楼主,2812中一条指令执行的时间是多小?如果晶振是30M,10倍频的话
例如:
void delay (unsigned int dly)        {
        unsigned int i;
        for ( ; dly>0; dly--)
                for (i=0; i<2000; i++);
}

如果是delay(1);那应该是延时多长时间?(我算出来感觉好像不对)谢谢啦~~~~

因为最近在做LCD驱动,时序老是不对.......郁闷中...

tiancaigao7 发表于 2009-7-21 19:50:00

楼上DSP里面有专门写好的延迟程序。你可以直接调用。

mpuhome 发表于 2009-7-21 20:57:51

好久没来了,最近太忙
tiancaigao7 天才杨威利 ,很热心啊,建议推举他为斑竹

xyzyx 发表于 2009-7-22 11:10:44

def _DSP28x_usDelay

;====================================================
;Delay Function
;The C assembly call will look as follows:
;
;extern void Delay(long time);               

;      MOV   AL,#LowLoopCount
;      MOV   AH,#HighLoopCount
;      LCR   _Delay
;
;Or as follows (if count is less then 16-bits):
;
;      MOV   ACC,#LoopCount
;      LCR   _Delay


      .global__DSP28x_usDelay
_DSP28x_usDelay:
      SUB    ACC,#1
      NOP
      NOP
      BF   _DSP28x_usDelay,GEQ    ;; Loop if ACC >= 0
      LRETR

;There is a 9/10 cycle overhead and each loop
;takes five cycles. The LoopCount is given by
;the following formula:

;DELAY_CPU_CYLES = 9 + 5*LoopCount

; LoopCount = (DELAY_CPU_CYCLES - 9) / 5

;==================================================

是这个吗?

tiancaigao7 发表于 2009-7-22 19:32:43

这个应该是一个,然后还有以他为基础的各个时间段的延迟程序。在TI的头文件目录里面都有。

chenxiaodiablo 发表于 2009-8-8 15:11:06

请问楼主:
    我在调试DSP2808 SCI时发现一个问题,在用FIFO模式时,上位机由于出错所发数据个数和我所设接受个数不一样,这几个数据就会一直存在于FIFO堆栈中,导致以后所发的正确数据串也被检测为误。请问怎样才能在不reset cpu的情况下丢掉存在FIFO中的错误数据?
   我尝试过很多方法:
   reset cpu   可以
   reset FIFO不行
   重新初始化SCI不行
   
   请大虾们解答
   谢谢

tiancaigao7 发表于 2009-8-8 17:30:01

恩,这个是一个问题,这也是为什么我一直不干把fifo设置太深的原因,目前我还没有找到比较好的办法,呵呵希望大家能发表一下意见。不过我倒是没有试过初始化fifo,你所谓的初始化fifo是不是指的是先禁止fifo功能,然后再开启fifo功能呢?

chenxiaodiablo 发表于 2009-8-9 15:29:02

恢复127楼:
    是的。我在SCI中断程序中采用了几种不同的方法,想删除FIFO堆栈中的错误数据:
    if(SciaRegs.SCIFFRX.bit.RXFFST!=0)
   { SciaRegs.SCIRXST.bit.BRKDT=1;
       SciaRegs.SCIFFTX.bit.SCIRST=0;
       SciaRegs.SCIFFRX.bit.RXFIFORESET=0;
       SciaRegs.SCIFFTX.bit.TXFIFOXRESET=0;
       SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
       SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;
       SciaRegs.SCIFFTX.bit.SCIFFENA=0;
       SciaRegs.SCIFFTX.bit.SCIFFENA=1;
       SciaRegs.SCIFFTX.bit.SCIRST=1;
       SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
       SciaRegs.SCIFFTX.bit.TXFFINTCLR=1;
       SCI_Init();
       SciaRegs.SCICTL2.bit.RXBKINTENA =0;       
       SciaRegs.SCICTL2.bit.RXBKINTENA =1;       
      }

   以上语句我都试过,想在SciaRegs.SCIFFRX.bit.RXFFST不为零时reset FIFO,从而删除FIFO中的数据,但是都没有成功。从watch窗口看RXFFST的值没有变化。只有在DEBUG中reset cpu才行。不知道大家有没有其他的办法??

cqaxgh 发表于 2009-8-9 16:27:55

请问楼主,我把GPIOA设置成I/O模式,怎样做才能输出一个方波?主频150M不分频,谢谢~~

tiancaigao7 发表于 2009-8-9 16:50:37

太困难了,楼上的要求几乎不可能实现,除非你的DSP什么都不敢专门产生方波,你还不如直接拿一个晶振自己倍频呢。

mpuhome 发表于 2009-8-11 08:25:14

可以用PWM产生方波

tiancaigao7 发表于 2009-8-14 20:16:41

请教一下IQ格式的问题,最近因为要写算法,因此一直在考虑这个问题,比如两个globalQ格式的变量相乘直接调用_IQmpy();这类的IQ格式专门的程序的时候,还需要考虑溢出的问题吗?我记得好像之前有人说过经验是 Q相乘等于Q值相加,那在这里还需要考虑这些问题吗?

cqaxgh 发表于 2009-8-15 17:56:32

请问如果我用的电机自带光电编码盘(ROD320)写着2500pulse/r那这表示编码盘的线数还是输出的脉冲数?

tiancaigao7 发表于 2009-8-15 20:23:00

应该是一圈有2500个脉冲吧

sunjianliang 发表于 2009-8-17 16:40:37

小弟初学dsp!最近申请了款TMS320F2801 ;但不知道怎么建最小系统(电源,复位,jtag下载等);能请大虾们上传个图吗?小弟不胜感激!!!!!!!!!

tiancaigao7 发表于 2009-8-18 08:22:22

从TI网站上下载他的开发板的原理图,直接按照图上的电路连接就可以了。

sunjianliang 发表于 2009-8-18 10:43:16

TMS320f2801官网没开发板!这款比较老了吧!

mpuhome 发表于 2009-8-18 12:11:29

可以参考2808的图,电源,复位,jtag下载等都一样

xyx2009xyx 发表于 2009-8-19 11:16:28

请问:我想将输入的24v隔离输出+-5v,其中+5v(电流2a左右)给dsp及其他元件供电,24v和+-5v完全隔离,不共地,如何实现?

tiancaigao7 发表于 2009-8-19 11:52:25

使用DCDC行不行。

mpuhome 发表于 2009-8-19 12:27:54

可以使用DC-DC
一般只有模拟电路部分才要完全隔离

sunjianliang 发表于 2009-8-26 21:21:43

楼主 推荐下TMS320F28*的仿真器和开发环境!
谢谢!

mpuhome 发表于 2009-8-27 10:13:35

开发环境就是CCS了,我现在用CCS3.3
仿真器可以用XDS510,淘宝上有不少山寨的,价格很实惠

xyx2009xyx 发表于 2009-8-27 21:04:52

不隔离也行的,但是由于24v的场合是电机控制,怕mos管的开关可能会干扰dsp的工作,不知道能帮我解决下

tiancaigao7 发表于 2009-8-28 10:18:13

在24V的输出加上电容去耦合和去干扰,还有使用质量比较好的5V稳压芯片,最后就是电机逆变器的GND和DSP的DGND 不要直接相连,之间使用一个0欧姆电阻。

sunjianliang 发表于 2009-9-8 16:14:22

>> warning: entry point other than _c_int00 specified

Build Complete,
0 Errors, 1 Warnings, 0 Remarks.

messages:
tting Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: Cannot access memory address 0x3FA06A
Trouble Removing Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: No breakpoint at 0x3FA06A.
Loader: One or more sections of your program falls into a memory region that is not writable.These regions will not actually be written to the target.Check your linker configuration and/or memory map.
GEL: Error while executing GEL_Go(main): Could not set breakpoint for GEL_Go()..
Trouble Setting Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: Cannot access memory address 0x3FA06A
Trouble Setting Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: Cannot access memory address 0x3FA06A
Trouble Removing Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: No breakpoint at 0x3FA06A.
Loader: One or more sections of your program falls into a memory region that is not writable.These regions will not actually be written to the target.Check your linker configuration and/or memory map.
GEL: Error while executing GEL_Go(main): Could not set breakpoint for GEL_Go()..
Trouble Setting Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: Cannot access memory address 0x3FA06A
这是什么问题?请大虾指点!!!!!

sunjianliang 发表于 2009-9-8 16:19:06

补充:
这是个2808的例子程序
点击此处打开 ourdev_478999.jpg(文件大小:526K,只有400K以内的图片才能直接显示) (原文件名:QQ截图未命名.jpg)

mpuhome 发表于 2009-9-9 09:26:59

>> warning: entry point other than _c_int00 specified
这个警告,是同时用了rts_lib和工程里的asm文件引起的,把asm文件从库里删除

下面的问题,你看看gel文件选的对不对?有条件的话,换个板子或者仿真器试试看

sunjianliang 发表于 2009-9-10 10:33:57

谢谢大侠!Warnings是解决了!
下面的问题还是没有解决!
Trouble Setting Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: Cannot access memory address 0x3FA06A
Trouble Setting Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: Cannot access memory address 0x3FA06A
Trouble Removing Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: No breakpoint at 0x3FA06A.
Loader: One or more sections of your program falls into a memory region that is not writable.These regions will not actually be written to the target.Check your linker configuration and/or memory map.
GEL: Error while executing GEL_Go(main): Could not set breakpoint for GEL_Go()..
Trouble Setting Breakpoint with the Action "Terminate Program Execution" at 0x3fa06a: Cannot access memory address 0x3FA06A
我的gel文件用的是例程中的gel文件!280*.gel
我还没用硬件仿真!直接用软件跑的!就出现这种问题!跑例程中的每个问题都会出现这种问题!是我的build options 设置有问题吗?还是没接硬件的原因,接了就可以了吗?
希望大虾帮忙解决下!万分感激!

mpuhome 发表于 2009-9-14 13:35:34

没接硬件?没试过哦,一直都是接了硬件仿镇的,你接了硬件看一下吧

yao_bit 发表于 2009-9-14 22:12:40

楼主您好,我想问一下,2808从flash启动的时候是不是一定得把GPIO18,29和34三个IO引脚拉高??我看有的开发板跟本没做任何处理呀

sunjianliang 发表于 2009-9-16 16:27:48

你好!
我的目标板是tms320f2801,仿真器是xds510(00ic) 环境是ccsv3.3
当我debug-connet连接正常(表明硬件正常吧),跑ti的例程v160-example-gpio_setup(由于是f2808的例程,我把cmd文件和gel文件换成f2801的。应该就可以了吧?) 出现下面的问题:
Build Complete,
0 Errors, 0 Warnings, 0 Remarks.
Loader: One or more sections of your program falls into a memory region that is not writable.These regions will not actually be written to the target.Check your linker configuration and/or memory map.
http://cache.amobbs.com/bbs_upload782111/files_18/ourdev_481523.jpg
(原文件名:QQ.jpg)
从提示上看是cmd文件有问题,但我看不出什么来!
/*
// TI File $Revision: /main/4 $
// Checkin $Date: August 2, 2006   16:56:52 $
//###########################################################################
//
// FILE:        F2801.cmd
//
// TITLE:        Linker Command File For F2801 Device
//
//###########################################################################
// $TI Release: DSP280x Header Files V1.60 $
// $Release Date: December 3, 2007 $
//###########################################################################
*/

/* ======================================================
// For Code Composer Studio V2.2 and later
// ---------------------------------------
// In addition to this memory linker command file,
// add the header linker command file directly to the project.
// The header linker command file is required to link the
// peripheral structures to the proper locations within
// the memory map.
//
// The header linker files are found in <base>\DSP280x_Headers\cmd
//   
// For BIOS applications add:      DSP280x_Headers_BIOS.cmd
// For nonBIOS applications add:   DSP280x_Headers_nonBIOS.cmd   
========================================================= */

/* ======================================================
// For Code Composer Studio prior to V2.2
// --------------------------------------
// 1) Use one of the following -l statements to include the
// header linker command file in the project. The header linker
// file is required to link the peripheral structures to the proper
// locations within the memory map                                    */

/* Uncomment this line to include file only for non-BIOS applications */
/* -l DSP280x_Headers_nonBIOS.cmd */

/* Uncomment this line to include file only for BIOS applications */
/* -l DSP280x_Headers_BIOS.cmd */

/* 2) In your project add the path to <base>\DSP280x_headers\cmd to the
   library search path under project->build options, linker tab,
   library search path (-i).
/*========================================================= */

/* Define the memory block start/length for the F2801
   PAGE 0 will be used to organize program sections
   PAGE 1 will be used to organize data sections

   Notes:
         Memory blocks on F2801 are uniform (ie same
         physical memory) in both PAGE 0 and PAGE 1.
         That is the same memory region should not be
         defined for both PAGE 0 and PAGE 1.
         Doing so will result in corruption of program
         and/or data.
         
         L0 memory block is mirrored - that is
         it can be accessed in high memory or low memory.
         For simplicity only one instance is used in this
         linker file.
         
         Contiguous SARAM memory blocks or flash sectors can be
         be combined if required to create a larger memory block.
*/

MEMORY
{
PAGE 0:    /* Program Memory */
         /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */
   RAML0       : origin = 0x008000, length = 0x001000   /* on-chip RAM block L0 */
   OTP         : origin = 0x3D7800, length = 0x000400   /* on-chip OTP */
   FLASHD      : origin = 0x3F4000, length = 0x001000   /* on-chip FLASH */
   FLASHC      : origin = 0x3F5000, length = 0x001000   /* on-chip FLASH */
   FLASHA      : origin = 0x3F7000, length = 0x000F80   /* on-chip FLASH */
   CSM_RSVD    : origin = 0x3F7F80, length = 0x000076   /* Part of FLASHA.Program with all 0x0000 when CSM is in use. */
   BEGIN       : origin = 0x3F7FF6, length = 0x000002   /* Part of FLASHA.Used for "boot to Flash" bootloader mode. */
   CSM_PWL   : origin = 0x3F7FF8, length = 0x000008   /* Part of FLASHA.CSM password locations in FLASHA */
   
   ROM         : origin = 0x3FF000, length = 0x000FC0   /* Boot ROM */
   RESET       : origin = 0x3FFFC0, length = 0x000002   /* part of boot ROM*/
   VECTORS   : origin = 0x3FFFC2, length = 0x00003E   /* part of boot ROM*/

PAGE 1 :   /* Data Memory */
         /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */
         /* Registers remain on PAGE1                                                */

   RAMM0       : origin = 0x000000, length = 0x000400   /* on-chip RAM block M0 */
   BOOT_RSVD   : origin = 0x000400, length = 0x000080   /* Part of M1, BOOT rom will use this for stack */
   RAMM1       : origin = 0x000480, length = 0x000380   /* on-chip RAM block M1 */
   FLASHB      : origin = 0x3F6000, length = 0x001000   /* on-chip FLASH */
}

/* Allocate sections to memory blocks.
   Note:
         codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code
                   execution when booting to flash
         ramfuncsuser defined section to store functions that will be copied from Flash into RAM
*/

SECTIONS
{

   /* Allocate program areas: */
   .cinit            : > FLASHA      PAGE = 0
   .pinit            : > FLASHA,   PAGE = 0
   .text               : > FLASHA      PAGE = 0
   codestart         : > BEGIN       PAGE = 0
   ramfuncs            : LOAD = FLASHD,
                         RUN = RAML0,
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart),
                         PAGE = 0

   csmpasswds          : > CSM_PWL   PAGE = 0
   csm_rsvd            : > CSM_RSVD    PAGE = 0
   
   /* Allocate uninitalized data sections: */
   .stack            : > RAMM0       PAGE = 1
   .ebss               : > RAMM1       PAGE = 1
   .esysmem            : > RAMM1       PAGE = 1

   /* Initalized sections go in Flash */
   /* For SDFlash to program these, they must be allocated to page 0 */
   .econst             : > FLASHA      PAGE = 0
   .switch             : > FLASHA      PAGE = 0      

   /* Allocate IQ math areas: */
   IQmath            : > FLASHC      PAGE = 0                  /* Math Code */
   IQmathTables      : > ROM         PAGE = 0, TYPE = NOLOAD   /* Math Tables In ROM */

   /* .reset is a standard section used by the compiler.It contains the */
   /* the address of the start of _c_int00 for C Code.   /*
   /* When using the boot ROM this section and the CPU vector */
   /* table is not needed.Thus the default type is set here to*/
   /* DSECT*/
   .reset            : > RESET,      PAGE = 0, TYPE = DSECT
   vectors             : > VECTORS   PAGE = 0, TYPE = DSECT

}

/*
//===========================================================================
// No more.
//===========================================================================
*/


请大侠帮忙分析下!

xakder 发表于 2009-9-22 16:01:34

【152楼】 sunjianliang
我想你是把地址映射到flash上了(.text: > FLASHA      PAGE = 0),当然load不进去,那是要烧写的。不知道对不对,我用DSP也只是照着例子改,没毛病了就烧,知其然而不知其所以然。

xakder 发表于 2009-9-22 16:08:10

问题1:2812划分flash空间时把空间截成了很多段,如果我一个程序长度超过了单个flash空间的长度,怎么把余下的程序放到另一个空间里?
问题2:2812往XINTF写数据,为什么地址线有动作了,数据线却没动作?以下是我的程序截取:
定义部分:
unsigned int * LedReg1= (unsigned int *) 0x2000;
unsigned int * LedReg2= (unsigned int *) 0x2f00;

动作部分:
while(1)
        {
        GpioDataRegs.GPBCLEAR.bit.GPIOB0=1;
        *LedReg1 =0xffFF;
        Delay();
        GpioDataRegs.GPBSET.bit.GPIOB0=1;
        *LedReg2 = 0x0000;
        Delay();
        }
我没有对XINTF做任何设置,但既然外部地址线都动作了,应该是已经访问外部接口了。

xiyouqiti 发表于 2009-9-22 17:25:56

初学2812,现在要用到CLARKE 和PARK变换,请教各位老手,分享一下编过的例程,万分感激!!!!!!!!!!!!!!!!

tiancaigao7 发表于 2009-9-23 08:20:46

我感觉也是这个问题,方针的时候是不能像flash里面烧写变量或者程序的。

zhuxuyan104 发表于 2009-9-24 21:50:04

请问2808的启动模式怎么配置啊,板子上有引出GPIO18,GPIO29,GPIO34。但是不知道怎么配置才能实现从H0方式启动

kztj 发表于 2009-9-25 10:52:18

感谢楼主!

我初学DSP,想用它做一个吉他定音器。
从麦克风采集吉他发出的声音,与标准音做比较,并作出指示(音调高了还是低了)。
怎样把吉他发出的音和环境的噪声分开呢?采集进来的信号用什么方法算出频率呢?DFT?
望给予一些指导为谢!

mpuhome 发表于 2009-9-25 10:56:05

157楼,请仔细查看数据手册

158楼,音频处理我实在不了解,我做工控产品的,所以这个我帮不了你哦,建议你发到总论坛,音频处理算法和CPU无关

ep02 发表于 2009-10-1 13:26:07

想实现2812串口编程,但是照着相关的文档(SDFlash_Serial_RefGuide_v3_3.pdf)做,将SCITXDA引脚接低电平(通过2.2K电阻接地),其余3个引脚按要求接低或高电平后,按复位按钮松开后,发现SCITXDA始终为高,用串口编程软件SDFlash连不上2812,似乎没有真正的进入SCI Boot Mode。将SCITXDA作为普通IO的话又可以输出高低电平。试了两块板子,都是这样。

SDFlash_Serial_RefGuide_v3_3.pdfourdev_487573.pdf(文件大小:341K) (原文件名:SDFlash_Serial_RefGuide_v3_3.pdf)

tiancaigao7 发表于 2009-10-4 16:58:19

我使用的是CCS3.3+补丁,仿真2808simulation形式,不连接仿真器。编译一个很简单的cputimer0中断导致GPIO端口反转的例子。使用的是2808头文件里面自带的“2808_RAM_lnk”这个cmd但是发现编译之后会有很多warning。但是我对比map检查了cmd没有问题,然后我就运行这个程序但是在加载out文件的时候出现了“Trouble Writing Memory Block at 0x3fb000 on Page 1 of Length 0x100: Cannot access memory address 0x3FB000”这个错误。希望大家帮忙分依稀下是哪里出现了问题?
对应的cmd上传到附件里面了。

仿真使用的2808 ram-cmdourdev_488221.rar(文件大小:2K) (原文件名:2808_RAM_lnk.rar)

下面是编译提示:
----------------------2808_gpio_interrupt.pjt - Debug----------------------
"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -pdsw225 -fr"E:/TMS320FXXX program/2808_GPIO_interrupt/2808_gpio_interrupt/Debug" -d"_DEBUG" -d"LARGE_MODEL" -ml -v28 -@"Debug.lkf" "2808_gpio_interrupt.c"
"2808_gpio_interrupt.c", line 42: warning: last line of file ends without a newline

"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -pdsw225 -fr"E:/TMS320FXXX program/2808_GPIO_interrupt/2808_gpio_interrupt/Debug" -d"_DEBUG" -d"LARGE_MODEL" -ml -v28 -@"Debug.lkf" "DSP280x_CpuTimers.c"

"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -pdsw225 -fr"E:/TMS320FXXX program/2808_GPIO_interrupt/2808_gpio_interrupt/Debug" -d"_DEBUG" -d"LARGE_MODEL" -ml -v28 -@"Debug.lkf" "DSP280x_DefaultIsr.c"

"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -pdsw225 -fr"E:/TMS320FXXX program/2808_GPIO_interrupt/2808_gpio_interrupt/Debug" -d"_DEBUG" -d"LARGE_MODEL" -ml -v28 -@"Debug.lkf" "DSP280x_GlobalVariableDefs.c"

"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -pdsw225 -fr"E:/TMS320FXXX program/2808_GPIO_interrupt/2808_gpio_interrupt/Debug" -d"_DEBUG" -d"LARGE_MODEL" -ml -v28 -@"Debug.lkf" "DSP280x_Gpio.c"

"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -pdsw225 -fr"E:/TMS320FXXX program/2808_GPIO_interrupt/2808_gpio_interrupt/Debug" -d"_DEBUG" -d"LARGE_MODEL" -ml -v28 -@"Debug.lkf" "DSP280x_PieCtrl.c"

"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -pdsw225 -fr"E:/TMS320FXXX program/2808_GPIO_interrupt/2808_gpio_interrupt/Debug" -d"_DEBUG" -d"LARGE_MODEL" -ml -v28 -@"Debug.lkf" "DSP280x_PieVect.c"

"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -pdsw225 -fr"E:/TMS320FXXX program/2808_GPIO_interrupt/2808_gpio_interrupt/Debug" -d"_DEBUG" -d"LARGE_MODEL" -ml -v28 -@"Debug.lkf" "DSP280x_SysCtrl.c"

"E:\program\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -@"Debug.lkf"
<Linking>
>> warning: creating output section CpuTimer2RegsFile without SECTIONS
            specification
>> warning: creating output section CpuTimer1RegsFile without SECTIONS
            specification
>> warning: creating output section FlashRegsFile without SECTIONS specification
>> warning: creating output section CpuTimer0RegsFile without SECTIONS
            specification
>> warning: creating output section CsmPwlFile without SECTIONS specification
>> warning: creating output section GpioIntRegsFile without SECTIONS
            specification
>> warning: creating output section SpicRegsFile without SECTIONS specification
>> warning: creating output section SpibRegsFile without SECTIONS specification
>> warning: creating output section ScibRegsFile without SECTIONS specification
>> warning: creating output section SpiaRegsFile without SECTIONS specification
>> warning: creating output section SciaRegsFile without SECTIONS specification
>> warning: creating output section CsmRegsFile without SECTIONS specification
>> warning: creating output section AdcMirrorFile without SECTIONS specification
>> warning: creating output section SpidRegsFile without SECTIONS specification
>> warning: creating output section XIntruptRegsFile without SECTIONS
            specification
>> warning: creating output section PieCtrlRegsFile without SECTIONS
            specification
>> warning: creating output section AdcRegsFile without SECTIONS specification
>> warning: creating output section ECap4RegsFile without SECTIONS specification
>> warning: creating output section ECap2RegsFile without SECTIONS specification
>> warning: creating output section ECap3RegsFile without SECTIONS specification
>> warning: creating output section ECap1RegsFile without SECTIONS specification
>> warning: creating output section GpioDataRegsFile without SECTIONS
            specification
>> warning: creating output section SysCtrlRegsFile without SECTIONS
            specification
>> warning: creating output section I2caRegsFile without SECTIONS specification
>> warning: creating output section EPwm1RegsFile without SECTIONS specification
>> warning: creating output section EPwm2RegsFile without SECTIONS specification
>> warning: creating output section EPwm3RegsFile without SECTIONS specification
>> warning: creating output section EPwm5RegsFile without SECTIONS specification
>> warning: creating output section EPwm4RegsFile without SECTIONS specification
>> warning: creating output section EPwm6RegsFile without SECTIONS specification
>> warning: creating output section ECanaRegsFile without SECTIONS specification
>> warning: creating output section ECanbRegsFile without SECTIONS specification
>> warning: creating output section ECanbLAMRegsFile without SECTIONS
            specification
>> warning: creating output section ECanaMOTORegsFile without SECTIONS
            specification
>> warning: creating output section ECanaLAMRegsFile without SECTIONS
            specification
>> warning: creating output section ECanaMOTSRegsFile without SECTIONS
            specification
>> warning: creating output section GpioCtrlRegsFile without SECTIONS
            specification
>> warning: creating output section ECanbMOTORegsFile without SECTIONS
            specification
>> warning: creating output section EQep1RegsFile without SECTIONS specification
>> warning: creating output section ECanbMOTSRegsFile without SECTIONS
            specification
>> warning: creating output section EQep2RegsFile without SECTIONS specification
>> warning: creating output section DevEmuRegsFile without SECTIONS
            specification
>> warning: creating output section PieVectTableFile without SECTIONS
            specification
>> warning: creating output section ECanbMboxesFile without SECTIONS
            specification
>> warning: creating output section ECanaMboxesFile without SECTIONS
            specification

Build Complete,
0 Errors, 46 Warnings, 0 Remarks.
下面是cmd内容:
/*
// TI File $Revision: /main/1 $
// Checkin $Date: September 16, 2005   13:06:33 $
//###########################################################################
//
// FILE:    2808_RAM_lnk.cmd
//
// TITLE:   Linker Command File For 2808 examples that run out of RAM
//
//          This ONLY includes all SARAM blocks on the 2808 device.
//          This does not include flash or OTP.
//
//          Keep in mind that L0 and L1 are protected by the code
//          security module.
//
//          What this means is in most cases you will want to move to
//          another memory map file which has more memory defined.
//
//###########################################################################
// $TI Release: DSP280x V1.30 $
// $Release Date: February 10, 2006 $
//###########################################################################
*/

/* ======================================================
// For Code Composer Studio V2.2 and later
// ---------------------------------------
// In addition to this memory linker command file,
// add the header linker command file directly to the project.
// The header linker command file is required to link the
// peripheral structures to the proper locations within
// the memory map.
//
// The header linker files are found in <base>\DSP281x_Headers\cmd
//   
// For BIOS applications add:      DSP280x_Headers_BIOS.cmd
// For nonBIOS applications add:   DSP280x_Headers_nonBIOS.cmd   
========================================================= */

/* ======================================================
// For Code Composer Studio prior to V2.2
// --------------------------------------
// 1) Use one of the following -l statements to include the
// header linker command file in the project. The header linker
// file is required to link the peripheral structures to the proper
// locations within the memory map                                    */

/* Uncomment this line to include file only for non-BIOS applications */
/* -l DSP280x_Headers_nonBIOS.cmd */

/* Uncomment this line to include file only for BIOS applications */
/* -l DSP280x_Headers_BIOS.cmd */

/* 2) In your project add the path to <base>\DSP280x_headers\cmd to the
   library search path under project->build options, linker tab,
   library search path (-i).
/*========================================================= */

/* Define the memory block start/length for the F2808
   PAGE 0 will be used to organize program sections
   PAGE 1 will be used to organize data sections

   Notes:
         Memory blocks on F2808 are uniform (ie same
         physical memory) in both PAGE 0 and PAGE 1.
         That is the same memory region should not be
         defined for both PAGE 0 and PAGE 1.
         Doing so will result in corruption of program
         and/or data.
         
         L0/L1 and H0 memory blocks are mirrored - that is
         they can be accessed in high memory or low memory.
         For simplicity only one instance is used in this
         linker file.
         
         Contiguous SARAM memory blocks can be combined
         if required to create a larger memory block.
*/


MEMORY
{
PAGE 0 :
   /* For this example, H0 is split between PAGE 0 and PAGE 1 */
   /* BEGIN is used for the "boot to SARAM" bootloader mode   */
   
   BEGIN      : origin = 0x000000, length = 0x000002            
   RAMM0      : origin = 0x000002, length = 0x0003FE
   RAML0      : origin = 0x008000, length = 0x001000   
   PRAMH0   : origin = 0x3FA000, length = 0x001000
   RESET      : origin = 0x3FFFC0, length = 0x000002
   BOOTROM    : origin = 0x3FF000, length = 0x000FC0               

         
PAGE 1 :

   /* For this example, H0 is split between PAGE 0 and PAGE 1 */

   RAMM1    : origin = 0x000400, length = 0x000400
   RAML1    : origin = 0x009000, length = 0x001000   
   DRAMH0   : origin = 0x3FB000, length = 0x001000         
}


SECTIONS
{
   /* Setup for "boot to SARAM" mode:
      The codestart section (found in DSP28_CodeStartBranch.asm)
      re-directs execution to the start of user code.*/
   codestart      : > BEGIN,   PAGE = 0
   ramfuncs         : > RAMM0      PAGE = 0
   .text            : > PRAMH0,    PAGE = 0
   .cinit         : > RAMM0,   PAGE = 0
   .pinit         : > RAMM0,   PAGE = 0
   .switch          : > RAMM0,   PAGE = 0
   .reset         : > RESET,   PAGE = 0, TYPE = DSECT /* not used, */
   
   .stack         : > RAMM1,   PAGE = 1
   .ebss            : > DRAMH0,    PAGE = 1
   .econst          : > DRAMH0,    PAGE = 1      
   .esysmem         : > RAMM1,   PAGE = 1

   IQmath         : >PRAMH0,   PAGE = 0
   IQmathTables   : >BOOTROM, type = NOLOAD, PAGE = 0

   
}

/*
//===========================================================================
// End of file.
//===========================================================================
*/

这是我的全部工程,请大家帮忙仿真一下,不需要链接仿真器simulation就可以。选择2808谢谢!!ourdev_488400.rar(文件大小:590K) (原文件名:GPIO_2808.rar)

carolxr 发表于 2009-10-14 19:40:34

最近使用28027遇到SCI数据接收中断问题,请楼主mpuhome 帮忙抽时间看看!谢谢!
    DSP每次上电时SCI的数据收发都正常,但是运行一段时间后(时间无规律,有时几秒钟,有时几分钟),SCI停止工作,接收不到数据,通过仿真器查看各变量,发现如下现象:
    SCI FIFO已经装满,SCI FIFO中断标志RXFFINT Flag也置位,但是PIEIFR9的bit0(SCIRX中断标志位)为零,如果通过仿真器将该位置1,强行进入SCI中断程序,程序能运行且从SCIFIFO中正常读入一个数据,退出中断后又出现如上现象不能正常进入中断。
    如果通过仿真器将SciaRegs.SCIFFRX.bit.RXFIFORESET位清零再置1,将scififo重启,SCI又重新正常工作,但是同样只能运行一段时间然后又停止工作。因此,我在中断程序中每读一个字节的数据就将SCIFIFO重启,这样貌似解决了SCI一旦停止工作就无法恢复的问题,但是每隔一段时间会丢失一些数据,应该还是之前这个问题导致的。下面是SCI接受中断函数:

//串口接收中断服务程序
void Sci_Int_Serv(void)
{
        Uint16 TempData;

        if(SciaRegs.SCIRXST.bit.RXERROR)
        {
                SciaRegs.SCIFFTX.bit.SCIRST = 0;
                asm(" NOP ");asm(" NOP ");
                SciaRegs.SCIFFTX.bit.SCIRST = 1;
                SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
        }

        while(SciaRegs.SCIFFRX.bit.RXFFST)        //SCI FIFO中有数据未读取
        {

             if(SciFlag.FrameReceiving)                //正在接收一帧数据...
                   {                                                            
                    TempData = SciaRegs.SCIRXBUF.all;                        
                                                                  
                SciaRegs.SCIFFRX.bit.RXFIFORESET = 0;                     
                asm(" NOP ");                                             
                SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
   
                DbgProtRxCnt++;                                       
                    *SciRxBuffPtr=TempData;                              
                    SciRxBuffPtr++;                                       
                    if(DbgProtRxCnt>=5)                                 
                    {                                                   
                             SciFlag.ReceiveComplete=1;                        
                               SciFlag.FrameReceiving=0;                        
                               FrameReceiving=0;                                 
                           SciFlag.ReceiveProtocol = 0;    //调试协议      
                           SciFlag.RespoProtocol=1;                        
                               DbgProtRxCnt=0;                                 
                     }
                   }                                                            
                 else    //判断起始标志                                    
                {                                                            
                                                                     
            SciRxBuff=SciaRegs.SCIRXBUF.all;                     
                                                                           
            SciaRegs.SCIFFRX.bit.RXFIFORESET = 0;                     
            asm(" NOP ");                                             
            SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;

            if(SciRxBuff==0x53)    //如果接收到的第一个字节为0x53则开始接收一帧数据                           
            {                                                         
                DbgProtRxCnt=1;                                       
                SciRxBuffPtr=&SciRxBuff;                           
                SciFlag.ReceiveComplete=0;                           
                SciFlag.FrameReceiving=1;
                FrameReceiving=1;                                    
                SciFlag.ReceiveProtocol = 1;    //调试协议            
                SciFlag.RespoProtocol=0;                              
            }                                                         
            else                                     //如果接收到的第一个字节不为0x53则丢弃                                 
            {                                                         
                SciFlag.ReceiveProtocol = 0;                        
                SciFlag.FrameReceiving=0;                           
                FrameReceiving=0;                                    
                ClientProtRxCnt=0;                                    
                SciRxBuffPtr=SciRxBuff;                              
            }
        }
                                                      
}

carolxr 发表于 2009-10-15 19:00:01

问题搞定了,是因为在任务中处理临界代码之前要关中断,而关中断的时间过长,SCI FIFO溢出导致数据丢失。

mpuhome 发表于 2009-10-16 15:18:39

163楼,厚道啊,问题解决了还来告诉大家,大家鼓励一下

我最近工作比较忙,很难抽出空来这里看一下,惭愧,对不住大家!

zhuxuyan104 发表于 2009-10-21 10:44:44

F2808总是会进入非法中断,是什么原因如何解决

zhuxuyan104 发表于 2009-10-21 10:46:18

F2808什么原因会产生EPWM中断,进入到中断函数中?该怎么解决

mpuhome 发表于 2009-10-21 12:01:13

你试一下ti提供的例子,确定一下是程序原因,还是硬件问题

archersky 发表于 2009-10-23 13:59:29

老大,还是问个SCI中FIFO的问题
书上写当TXFFST和TXFFIL匹配时(小于或等于)发生发送中断
到底是TXFFST小于或等于TXFFIL,还是TXFFIL小于或等于TXFFST呢?
接收时也是
到底是RXFFST大于或等于RXFFIL,还是RXFFIL大于或等于RXFFST呢?

tiancaigao7 发表于 2009-10-24 21:02:04

按照顺序比较。

jwp2008 发表于 2009-10-27 17:28:07

请教一下楼主:
我现在用2812的SCIB收发数据,用中断接收,查询发送,可在程序运行时出现如下问题:
如果我在接收中断程序中判断如果接收错误中断标志位为1时,我就软件复位一下SCI,这样我就接收不到另外的节点发过来的数据,如果我不复位,就永远也进不了中断了。另外,我查看了一下SCI接收状态寄存器,其值为0xfa,但我没有其它节点给它发送数据,不知怎么会出现接收错误呢?我检查了一下也并没有设置自发自收的功能啊,那么这个接收中断错误会是什么引起的呢?如有需要可以把相关程序贴出来,另外,说明一下,我这个程序在SCIA上运行没有问题,收发都正常,可是用到SCIB上就出现这样的情况,请高手们给我看看。
楼主方便告知你的邮箱地址吗?

sunjianliang 发表于 2009-11-10 14:35:59

请教I2C问题:
/ I2CMessage Commands for I2CMSG struct
#define I2C_MSGSTAT_INACTIVE          0x0000
#define I2C_MSGSTAT_SEND_WITHSTOP   0x0010
#define I2C_MSGSTAT_WRITE_BUSY      0x0011
#define I2C_MSGSTAT_SEND_NOSTOP       0x0020
#define I2C_MSGSTAT_SEND_NOSTOP_BUSY0x0021
#define I2C_MSGSTAT_RESTART         0x0022
#define I2C_MSGSTAT_READ_BUSY         0x0023
这部分是怎么理解的?0x00000x0010 0x0011 0x0020 0x0021 0x0022这些值是怎么来的?
源代码如下:
// TI File $Revision: /main/5 $
// Checkin $Date: April 4, 2007   17:18:36 $
//###########################################################################
//
// FILE:    Example_280xI2c_eeprom.c
//
// TITLE:   DSP280x I2C EEPROM Example
//
// ASSUMPTIONS:
//
//    This program requires the DSP280x header files.
//
//    This program requires an external I2C EEPROM connected to
//    the I2C bus at address 0x50.
//
//    As supplied, this project is configured for "boot to SARAM"
//    operation.The 280x Boot Mode table is shown below.
//    For information on configuring the boot mode of an eZdsp,
//    please refer to the documentation included with the eZdsp,
//
//       Boot      GPIO18   GPIO29    GPIO34
//       Mode      SPICLKA    SCITXDA
//                  SCITXB
//       -------------------------------------
//       Flash       1          1      1
//       SCI-A       1          1      0
//       SPI-A       1          0      1
//       I2C-A       1          0      0
//       ECAN-A      0          1      1
//       SARAM       0          1      0<- "boot to SARAM"
//       OTP         0          0      1
//       I/0         0          0      0
//
// DESCRIPTION:
//
//    This program will write 1-14 words to EEPROM and read them back.
//    The data written and the EEPROM address written to are contained
//    in the message structure, I2cMsgOut1. The data read back will be
//    contained in the message structure I2cMsgIn1.
//    --------------------------------------------------------------
//    CODE MODIFICATIONS ARE REQUIRED FOR 60 MHZ DEVICES (In
//    DSP280x_Examples.h in the common/include/ directory, set
//    #define CPU_FRQ_60MHZ to 1, and #define CPU_FRQ_100MHZ to 0).
//    --------------------------------------------------------------
//    This program will work with the on-board I2C EEPROM supplied on
//    the F280x eZdsp.
//
//
//###########################################################################
// Original Author: D.F.
//
// $TI Release: DSP280x C/C++ Header Files V1.70 $
// $Release Date: July 27, 2009 $
//###########################################################################


#include "DSP280x_Device.h"   // DSP280x Headerfile Include File
#include "DSP280x_Examples.h"   // DSP280x Examples Include File

// Note: I2C Macros used in this example can be found in the
// DSP280x_I2C_defines.h file

// Prototype statements for functions found within this file.
void   I2CA_Init(void);
Uint16 I2CA_WriteData(struct I2CMSG *msg);
Uint16 I2CA_ReadData(struct I2CMSG *msg);
interrupt void i2c_int1a_isr(void);
void pass(void);
void fail(void);

#define I2C_SLAVE_ADDR      0x50
#define I2C_NUMBYTES          4
#define I2C_EEPROM_HIGH_ADDR0x00
#define I2C_EEPROM_LOW_ADDR   0x30

// Global variables
// Two bytes will be used for the outgoing address,
// thus only setup 14 bytes maximum
struct I2CMSG I2cMsgOut1={I2C_MSGSTAT_SEND_WITHSTOP,
                        I2C_SLAVE_ADDR,
                        I2C_NUMBYTES,
                        I2C_EEPROM_HIGH_ADDR,
                        I2C_EEPROM_LOW_ADDR,
                        0x12,                   // Msg Byte 1
                        0x34,                   // Msg Byte 2
                        0x56,                   // Msg Byte 3
                        0x78,                   // Msg Byte 4
                        0x9A,                   // Msg Byte 5
                        0xBC,                   // Msg Byte 6
                        0xDE,                   // Msg Byte 7
                        0xF0,                   // Msg Byte 8
                        0x11,                   // Msg Byte 9
                        0x10,                   // Msg Byte 10
                        0x11,                   // Msg Byte 11
                        0x12,                   // Msg Byte 12
                        0x13,                   // Msg Byte 13
                        0x12};                  // Msg Byte 14


struct I2CMSG I2cMsgIn1={ I2C_MSGSTAT_SEND_NOSTOP,
                        I2C_SLAVE_ADDR,
                        I2C_NUMBYTES,
                        I2C_EEPROM_HIGH_ADDR,
                        I2C_EEPROM_LOW_ADDR};

struct I2CMSG *CurrentMsgPtr;                                // Used in interrupts
Uint16 PassCount;
Uint16 FailCount;

void main(void)
{
   Uint16 Error;
   Uint16 i;

   CurrentMsgPtr = &I2cMsgOut1;

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP280x_SysCtrl.c file.
   InitSysCtrl();


// Step 2. Initalize GPIO:
// This example function is found in the DSP280x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();
// Setup only the GP I/O only for I2C functionality
   InitI2CGpio();

// 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 DSP280x_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 DSP280x_DefaultIsr.c.
// This function is found in DSP280x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;        // This is needed to write to EALLOW protected registers
   PieVectTable.I2CINT1A = &i2c_int1a_isr;
   EDIS;   // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP280x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   I2CA_Init();

// Step 5. User specific code

   // Clear Counters
   PassCount = 0;
   FailCount = 0;

   // Clear incoming message buffer
   for (i = 0; i < I2C_MAX_BUFFER_SIZE; i++)
   {
       I2cMsgIn1.MsgBuffer = 0x0000;   //读入缓存清零
   }

// Enable interrupts required for this example

// Enable I2C interrupt 1 in the PIE: Group 8 interrupt 1
   PieCtrlRegs.PIEIER8.bit.INTx1 = 1;

// Enable CPU INT8 which is connected to PIE group 8
   IER |= M_INT8;
   EINT;

   // Application loop
   for(;;)
   {
      //////////////////////////////////
      // Write data to EEPROM section //
      //////////////////////////////////

      // Check the outgoing message to see if it should be sent.
      // In this example it is initialized to send with a stop bit.
      if(I2cMsgOut1.MsgStatus == I2C_MSGSTAT_SEND_WITHSTOP)
      {
         Error = I2CA_WriteData(&I2cMsgOut1);
         // If communication is correctly initiated, set msg status to busy
         // and update CurrentMsgPtr for the interrupt service routine.
         // Otherwise, do nothing and try again next loop. Once message is
         // initiated, the I2C interrupts will handle the rest. Search for
         // ICINTR1A_ISR in the i2c_eeprom_isr.c file.
         if (Error == I2C_SUCCESS)
         {
            CurrentMsgPtr = &I2cMsgOut1;
            I2cMsgOut1.MsgStatus = I2C_MSGSTAT_WRITE_BUSY;
         }
      }// end of write section

      ///////////////////////////////////
      // Read data from EEPROM section //
      ///////////////////////////////////

      // Check outgoing message status. Bypass read section if status is
      // not inactive.不停止的
      if (I2cMsgOut1.MsgStatus == I2C_MSGSTAT_INACTIVE)
      {
         // Check incoming message status.
         if(I2cMsgIn1.MsgStatus == I2C_MSGSTAT_SEND_NOSTOP)
         {
            // EEPROM address setup portion
            while(I2CA_ReadData(&I2cMsgIn1) != I2C_SUCCESS)
            {
               // Maybe setup an attempt counter to break an infinite while
               // loop. The EEPROM will send back a NACK while it is performing
               // a write operation. Even though the write communique is
               // complete at this point, the EEPROM could still be busy
               // programming the data. Therefore, multiple attempts are
               // necessary.
            }
            // Update current message pointer and message status
            CurrentMsgPtr = &I2cMsgIn1;
            I2cMsgIn1.MsgStatus = I2C_MSGSTAT_SEND_NOSTOP_BUSY;
         }

         // Once message has progressed past setting up the internal address
         // of the EEPROM, send a restart to read the data bytes from the
         // EEPROM. Complete the communique with a stop bit. MsgStatus is
         // updated in the interrupt service routine.
         else if(I2cMsgIn1.MsgStatus == I2C_MSGSTAT_RESTART)
         {
            // Read data portion
            while(I2CA_ReadData(&I2cMsgIn1) != I2C_SUCCESS)
            {
               // Maybe setup an attempt counter to break an infinite while
               // loop.
            }
            // Update current message pointer and message status
            CurrentMsgPtr = &I2cMsgIn1;
            I2cMsgIn1.MsgStatus = I2C_MSGSTAT_READ_BUSY;
         }
      }// end of read section

   }   // end of for(;;)
}   // end of main


void I2CA_Init(void)
{
   // Initialize I2C
   I2caRegs.I2CSAR = 0x0050;                // Slave address - EEPROM control code

   #if (CPU_FRQ_100MHZ)             //Tmod the period of the module clock
   I2caRegs.I2CPSC.all = 9;                // Prescaler - need 7-12 Mhz on module clk
   #endif
   #if (CPU_FRQ_60MHZ)
   I2caRegs.I2CPSC.all = 6;                // Prescaler - need 7-12 Mhz on module clk
   #endif                           //Tmst The period of the master clock
                                    //Tmst=Tmod*[( ICCL+d )+( ICCH+d )]
   I2caRegs.I2CCLKL = 10;                        // NOTE: must be non zero
   I2caRegs.I2CCLKH = 5;                        // NOTE: must be non zero
   I2caRegs.I2CIER.all = 0x24;                // Enable SCD & ARDY interrupts

   I2caRegs.I2CMDR.all = 0x0020;        // Take I2C out of reset
                                                                           // Stop I2C when suspended

   I2caRegs.I2CFFTX.all = 0x6000;        // Enable FIFO mode and TXFIFO
   I2caRegs.I2CFFRX.all = 0x2040;        // Enable RXFIFO, clear RXFFINT,

   return;
}


Uint16 I2CA_WriteData(struct I2CMSG *msg)
{
   Uint16 i;

   // Wait until the STP bit is cleared from any previous master communication.
   // Clearing of this bit by the module is delayed until after the SCD bit is
   // set. If this bit is not checked prior to initiating a new message, the
   // I2C could get confused.
   if (I2caRegs.I2CMDR.bit.STP == 1) //STP bit Clear by the module is delayed until after the SCD bit is set
   {                                 //SCD:Stop condition detected interrupt enable bit
      return I2C_STP_NOT_READY_ERROR;
   }

   // Setup slave address
   I2caRegs.I2CSAR = msg->SlaveAddress;

   // Check if bus busy
   if (I2caRegs.I2CSTR.bit.BB == 1)
   {
      return I2C_BUS_BUSY_ERROR;
   }

   // Setup number of bytes to send
   // MsgBuffer + Address
   I2caRegs.I2CCNT = msg->NumOfBytes+2; //2指MemoryHighAddr MemoryLowAddr

   // Setup data to send
   I2caRegs.I2CDXR = msg->MemoryHighAddr;
   I2caRegs.I2CDXR = msg->MemoryLowAddr;
// for (i=0; i<msg->NumOfBytes-2; i++)
   for (i=0; i<msg->NumOfBytes; i++)

   {
      I2caRegs.I2CDXR = *(msg->MsgBuffer+i);
   }

   // Send start as master transmitter
   I2caRegs.I2CMDR.all = 0x6E20;

   return I2C_SUCCESS;
}


Uint16 I2CA_ReadData(struct I2CMSG *msg)
{
   // Wait until the STP bit is cleared from any previous master communication.
   // Clearing of this bit by the module is delayed until after the SCD bit is
   // set. If this bit is not checked prior to initiating a new message, the
   // I2C could get confused.
   if (I2caRegs.I2CMDR.bit.STP == 1)
   {
      return I2C_STP_NOT_READY_ERROR;
   }

   I2caRegs.I2CSAR = msg->SlaveAddress;

   if(msg->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP)
   {
      // Check if bus busy
      if (I2caRegs.I2CSTR.bit.BB == 1)
      {
         return I2C_BUS_BUSY_ERROR;
      }
      I2caRegs.I2CCNT = 2;
      I2caRegs.I2CDXR = msg->MemoryHighAddr;
      I2caRegs.I2CDXR = msg->MemoryLowAddr;
      I2caRegs.I2CMDR.all = 0x2620;                        // Send data to setup EEPROM address
   }
   else if(msg->MsgStatus == I2C_MSGSTAT_RESTART)
   {
      I2caRegs.I2CCNT = msg->NumOfBytes;        // Setup how many bytes to expect
      I2caRegs.I2CMDR.all = 0x2C20;                        // Send restart as master receiver
   }

   return I2C_SUCCESS;
}

interrupt void i2c_int1a_isr(void)   // I2C-A
{
   Uint16 IntSource, i;

   // Read interrupt source
   IntSource = I2caRegs.I2CISRC.all;

   // Interrupt source = stop condition detected
   if(IntSource == I2C_SCD_ISRC)
   {
      // If completed message was writing data, reset msg to inactive state
      if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_WRITE_BUSY)
      {
         CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
      }
      else
      {
         // If a message receives a NACK during the address setup portion of the
         // EEPROM read, the code further below included in the register access ready
         // interrupt source code will generate a stop condition. After the stop
         // condition is received (here), set the message status to try again.
         // User may want to limit the number of retries before generating an error.
         if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
         {
            CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_SEND_NOSTOP;
         }
         // If completed message was reading EEPROM data, reset msg to inactive state
         // and read data from FIFO.
         else if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_READ_BUSY)
         {
            CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
            for(i=0; i < I2C_NUMBYTES; i++)
            {
            CurrentMsgPtr->MsgBuffer = I2caRegs.I2CDRR;
            }
         {
         // Check recieved data
         for(i=0; i < I2C_NUMBYTES; i++)
         {
            if(I2cMsgIn1.MsgBuffer == I2cMsgOut1.MsgBuffer)
            {
                PassCount++;
            }
            else
            {
                FailCount++;
            }
         }
         if(PassCount == I2C_NUMBYTES)
         {
            pass();
         }
         else
         {
            fail();
         }


      }

    }
      }
   }// end of stop condition detected

   // Interrupt source = Register Access Ready
   // This interrupt is used to determine when the EEPROM address setup portion of the
   // read data communication is complete. Since no stop bit is commanded, this flag
   // tells us when the message has been sent instead of the SCD flag. If a NACK is
   // received, clear the NACK bit and command a stop. Otherwise, move on to the read
   // data portion of the communication.
   else if(IntSource == I2C_ARDY_ISRC)
   {
      if(I2caRegs.I2CSTR.bit.NACK == 1)
      {
         I2caRegs.I2CMDR.bit.STP = 1;
         I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
      }
      else if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
      {
         CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;
      }
   }// end of register access ready

   else
   {
      // Generate some error due to invalid interrupt source
      asm("   ESTOP0");
   }

   // Enable future I2C (PIE Group 8) interrupts
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}

void pass()
{
    asm("   ESTOP0");
    for(;;);
}

void fail()
{
    asm("   ESTOP0");
    for(;;);
}


//===========================================================================
// No more.
//===========================================================================

最好能帮我讲解下例子中的收发时序?尤其是各个状态位I2C_MSGSTAT的理解?
多谢大侠们帮忙解答!不胜感激!!!!!!

rxbin 发表于 2009-11-11 09:09:38

楼主你好,我想用2812做1602液晶显示,但是怎么调试都不行,请问有没有建议啊,我用的是gpioa0^7做数据线和地址线,用gpiob0^2做控制,直接连的,就是不好使,请高手指点,谢谢!!!!!!!!

tiancaigao7 发表于 2009-11-12 07:56:46

怎么不行??延迟要弄好,否则液晶容易画屏或者别的毛病

mpuhome 发表于 2009-11-12 09:38:41

肯定可以的,延迟1us就差不多了,你看LCD的时序要求

chenwu0901 发表于 2009-11-16 19:41:35

您好楼主,我刚开始接触DSP,想问你个问题,我用的是F2812,软件是CCS2.2,仿真器是合众达的XDSPP并口仿真器,打开软件和用SD复位都没问题,但每次一烧写就提示我
code composer could not locate:
FlashAPIInterface.c
would you like to browse for it?
然后CCS就自动关闭了,只是怎么回事啊?急,谢谢啊!

gaeshine 发表于 2009-11-20 11:08:28

刚才看到楼上的疑问,关于SCI FIFO无法清除中断标志,我之前做MCBSP的发送FIFO也遇到相同的问题,无法清除中断标志,后来找到问题所在,发送FIFO必须要有数据才可以清零中断标志,所以我在发送时候写入一个数据再开始使能中断,到了中断关闭中断,等待下一次发送再开启中断,希望对你有帮助

power668 发表于 2009-11-21 11:01:34

请教CAN通信问题:
我想用F283x的CAN通信功能,多站工作方式,请教设计编程步骤,哪里能找到有关代码?谢谢!

lilijunpx 发表于 2009-11-22 22:19:23

标记

panhua223 发表于 2009-11-25 13:33:24

TMS320F2808 在线仿真可以,下载到FLASH后,程序不跑

kuzhuu 发表于 2009-11-25 15:42:49

DSP看了快一个礼拜了,看的很晕,现在只是基本上了解了些头文件,也一知半解的模糊式的看了下CMD文件是怎么回事,但是到现在还是
不知道怎么去建立一个工程,建了工程一编译就一大堆的错误,很无奈,我刚学DSP的时候,人家都说DSP就和单片机一样,比较简单,就是速度比
单片机快,适合做复杂的运算,结果到现在连个工程都不能编译,还望高手给予直接的回答,说说建立一个工程的步骤,要包含一些
什么文件,谢谢,很谢谢!!

kuzhuu 发表于 2009-11-26 11:04:21

我想问下CMD文件编辑好了过后,那与我们写DSP程序有什么关系,.text那要怎么在程序里面体现出来呢v......
   谢谢了

sunjianliang 发表于 2009-12-1 19:25:10

Flash 烧写求助!
用的TMS320F2801 内部有32Kflash 。在ram中跑的话掉电程序就没了,所以要加载到内部flash中去。
我现在时搞不清楚烧写flash的具体步骤:请大侠写个详细点的说明吧!感激不尽!!!!!
除了要休改cmd文件(把ram cmd换成flash cmd)还需要做点什么 我用的CCS3.3的 on chip programmer是自带的。
是否Boot    Mode   GPIO18   GPIO29    GPIO34 需要上啦到高电平? 是否需要如下图修改:
点击此处打开 ourdev_509573.jpg(文件大小:410K,只有400K以内的图片才能直接显示) (原文件名:QQ截图未命名.jpg)

tiancaigao7 发表于 2009-12-1 21:34:40

183楼的问题是需要在主程序中添加flash的初始化和copy函数,将程序从flash中拷贝到ram中来运行,同时你定义的函数也要在flash中分配地址。
182楼的问题很简单cmd就是一个分配表,相当于给DSP做一个格式化,.text这类变量都有自己代表的具体内容怎么分配是编译器的工作,他会将你程序里面的各个成分按照你的cmd文件放到对应的区域里面。

wavebo 发表于 2009-12-8 08:52:19

我想问下关于2808核心板的PCB应该在那些地方要多加注意的?谢谢

tidsp 发表于 2009-12-8 09:05:18

180楼的问题应该是CMD文件不对,程序入口地址不对。找TI网站例子的CMD文件,或者干脆在例子工程上改自己的程序

mpuhome 发表于 2009-12-8 10:25:31

176楼,应该是你的FLASH烧写软件设置不正确导致的,建议直接电话合众达,很快解决问题的

178楼,你的问题及句话说不清楚,可以这么考虑,如果一群人讲话,应该怎么办呢?可以参考现成的 canopen等协议

185楼,注意EMC合散热

最近忙着照顾才出生的女儿,很少来了,对不住大家

sym2008 发表于 2009-12-10 21:57:24

tms320f2812 有一个严格的上电顺序,TI给出的解决方案是给出了一个对应的电源芯片,来控制IO和内核的上电顺序。
我想问一下,不用它的那个芯片,有没有其他的电源方案?
比如用1117-3.3给IO供电,1117-1.8给内核供电。
如果直接用两片1117,不去控制上电顺序行不行?会不会出现什么问题?
如果我加一个开关,手动控制上电顺序可行不?

mpuhome 发表于 2009-12-11 08:56:54

如果成本没问题,就用TI推荐方案
想省钱,就用1117吧,也是可以的

tidsp 发表于 2009-12-11 09:12:44

280X电源可以不分顺序的,但先上IO电源再上内核可能会导致IO短暂异常输出,VIO到Vcore加个二极管就可以解决。见文档SPRS230J

6.8 Power Sequencing
No requirements are placed on the power up/down sequence of the various power pins to ensure the
correct reset state for all the modules. However, if the 3.3-V transistors in the level shifting output buffers
of the I/O pins are powered prior to the 1.8-V transistors, it is possible for the output buffers to turn on,
causing a glitch to occur on the pin during power up. To avoid this behavior, power the V DD (core voltage)
pins prior to or simultaneously with the V DDIO (input/output voltage) pins, ensuring that the V DD pins have
reached 0.7 V before the V DDIO pins reach 0.7 V.
There are some requirements on the XRS pin:
1. During power up, the XRS pin must be held low for t w(RSL1) after the input clock is stable (see
Table 6-13 ). This is to enable the entire device to start from a known condition.
2. During power down, the XRS pin must be pulled low at least 8 μ s prior to V DD reaching 1.5 V. This is to
enhance flash reliability.
Additionally it is recommended that no voltage larger than a diode drop (0.7 V) should be applied to any
pin prior to powering up the device. Voltages applied to pins on an unpowered device can bias internal p-n
junctions in unintended ways and produce unpredictable results.

haishanggudao 发表于 2010-1-11 11:04:36

楼主你好,我正在用F2808做SPWM的程序,能提供个例子吗?

haishanggudao 发表于 2010-1-11 11:10:36

如果有2808的spwm程序,能麻烦你发我邮箱吗?tonghua5225@126.com,万分感谢!!!!!

zhanglei_hrb 发表于 2010-1-11 16:50:04

记号下,正着手学习,到时必有求与你啊!

simplorer 发表于 2010-1-12 16:15:55

F2812 ADC数据手册上有这么一段汇编:
MOV ADCTRL1, #01xxxxxxxxxxxxxxb; Resets the ADC (RESET = 1)
RPT #10 || NOP ; Provides the required delay between writes to ADCTRL1
这段汇编的目的是使ADC复位后,产生至少2个clock cycle的延迟(芯片要求的),用来满足ADC复位信号的要求。
这段汇编是F2812工作于150MHz,ADCCLK为25MHz的延时代码,这里为什么需要10个NOP?
根据我的观察,一条NOP指令需要3个CC执行,哪位可以给我释疑,谢谢!

kunyi 发表于 2010-1-27 20:49:49

楼主好,我是机械专业的,初次接触F2812,请教楼主,我的F2812仿真板上的DA芯片是芯片TLC7528,它有两路DA输出,精度是8位的,我可否将两路级联起来使其输出精度为16位?

kunyi 发表于 2010-1-28 18:51:49

感觉没人气了啊。。。

wavebo 发表于 2010-3-20 10:50:33

关于SPWM产生正弦波的问题


#include "DSP280x_Device.h"   // DSP280x Headerfile Include File
#include "DSP280x_Examples.h"   // DSP280x Examples Include File
#include "IQmathLib.h"
// Prototype statements for functions found within this file.
void InitEPwm1Example(void);
interrupt void epwm1_isr(void);
#define PI 3.1415926
_iq27 pwmsin,Pi;
unsigned intEPWM1_TIMER_TBPRD;
unsigned intflt,n,T1,counter;
floati,j,T,T0,t,t1,f,flt1;
unsigned char flat;

void main(void)
{
flat = 1;
i=0;
f=1000;
T=1/f;
T0 = T*600000;
counter = (Uint16)(T0);

EPWM1_TIMER_TBPRD=100;

// This example function is found in the DSP2802x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the DSP2802x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();// Skipped for this example

// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
// These functions are in the DSP2802x_EPwm.c file
   InitEPwm1Gpio();


// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize the 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 DSP2802x_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 DSP2802x_DefaultIsr.c.
// This function is found in DSP2802x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;// This is needed to write to EALLOW protected registers
   PieVectTable.EPWM1_INT = &epwm1_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2802x_InitPeripherals.c
// InitPeripherals();// Not required for this example

// For this example, only initialize the ePWM

   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
   EDIS;

   InitEPwm1Example();

   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
   EDIS;


// Step 5. User specific code, enable interrupts:

// Enable CPU INT3 which is connected to EPWM1-3 INT:
   IER |= M_INT3;

// Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
   PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
   PieCtrlRegs.PIEIER3.bit.INTx2 = 1;
   PieCtrlRegs.PIEIER3.bit.INTx3 = 1;

// Enable global Interrupts and higher priority real-time debug events:
   EINT;   // Enable Global interrupt INTM
   ERTM;   // Enable Global realtime interrupt DBGM

// Step 6. IDLE loop. Just sit and loop forever (optional):

    for(;;)
        {
       asm("          NOP");
        }

}

interrupt void epwm1_isr(void)
{
   // Update the CMPA and CMPB values
   //update_compare(&epwm1_info);

                if(i<=2*PI)
                {
                           Pi=_IQ27(i);
                           pwmsin= _IQ27sin(Pi);
                    j=_IQ27toF(pwmsin)+1;
                    t=j/2.0*100.0;
                    flt=(Uint16)(t);

               

                    EPwm1Regs.CMPA.half.CMPA =flt;

                            i = i + 2.0*PI/counter;
                }
                else
                {
                i=0;                   

                }
   // Clear INT flag for this timer
   EPwm1Regs.ETCLR.bit.INT = 1;
   // Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
   
       
}



void InitEPwm1Example()
{

   // Setup TBCLK
   EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
// EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
   EPwm1Regs.TBPRD = EPWM1_TIMER_TBPRD;       // Set timer period
   EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;    // Disable phase loading
//EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
   EPwm1Regs.TBPHS.half.TBPHS = 0x0000;       // Phase is 0
   EPwm1Regs.TBCTR = 0x0000;                  // Clear counter
   EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;   // Clock ratio to SYSCLKOUT
   //EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV2;
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
   // Setup shadow register load on ZERO
   EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
   EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
   EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
   EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

   // Set Compare values
// EPwm1Regs.CMPA.half.CMPA = EPWM1_MIN_CMPA;    // Set compare A value
   // Set actions
   //****************************************
   EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET;            // Set PWM1A on Zero
   EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;          // Clear PWM1A on event A, up count
   //******************************************
// EPwm1Regs.AQCTLA.bit.PRD = AQ_CLEAR;
// EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;
   // Clear PWM1B on event B, up count

   // Interrupt where we will change the Compare Values
   EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;   // Select INT on Zero event
   EPwm1Regs.ETSEL.bit.INTEN = 1;                // Enable INT
// EPwm1Regs.ETPS.bit.INTPRD = ET_3RD;         // Generate INT on 3rd event
        EPwm1Regs.ETPS.bit.INTPRD = ET_1ST;
}

我用的是改变占空比的方法产生正弦波,输入为设定的一个频率大小值,程序中以脉冲周期恒定,脉冲个数可调来实现信号周期的变化。输出为一个与输入相对应的SPWM信号,通过滤波产生正弦波。
问题:通过公式:1/f_sin/counter=f_pulse=C*(1/f_sys) ( f_sin:设定输出信号的频率值。counter:信号周期中单位脉冲个数。f_pulse:单位脉冲的频率。C:单位脉冲周期的计数值。f_sys:系统时钟。)计算出相应的各个参数,但是现在我计算出来的数据和实际的不一致
谢谢大家指教!!!

monster555 发表于 2010-3-27 17:23:59

回复【楼主位】mpuhome
-----------------------------------------------------------------------

你好,请问如何在2809上实现中断嵌套呢?能否给个例程?谢谢!

yinhua 发表于 2010-3-28 10:08:17

有问题:不明白如何用epwm来启动ADC,硬件上需要有什么要的链接呢?????

// TI File $Revision: /main/2 $
// Checkin $Date: November 7, 2008   16:33:22 $
//###########################################################################
//
// FILE:   Example_2802xAdcSoc.c
//
// TITLE:DSP2802x ADC Start-Of-Conversion (SOC) Example Program.
//
// ASSUMPTIONS:
//
//   This program requires the DSP2802x header files.
//
//   Make sure the CPU clock speed is properly defined in
//   DSP2802x_Examples.h before compiling this example.
//
//   Connect signals to be converted to A2 and A3.
//
//    As supplied, this project is configured for "boot to SARAM"
//    operation.The 2802x Boot Mode table is shown below.
//    For information on configuring the boot mode of an eZdsp,
//    please refer to the documentation included with the eZdsp,
//
//       Boot      GPIO18   GPIO29    GPIO34
//       Mode      SPICLKA    SCITXDA
//               SCITXB
//       -------------------------------------
//       Flash       1          1      1
//       SCI-A       1          1      0
//       SPI-A       1          0      1
//       I2C-A       1          0      0
//       ECAN-A      0          1      1
//       SARAM       0          1      0<- "boot to SARAM"
//       OTP         0          0      1
//       I/0         0          0      0
//
//
// DESCRIPTION:
//
//   This example sets up the PLL in x12/2 mode.
//
//   For 60 MHz devices (default)
//   (assuming a 10Mhz input clock).
//
//   Interrupts are enabled and the ePWM1 is setup to generate a periodic
//   ADC SOC - ADCINT1. Two channels are converted, ADCINA4 and ADCINA2.
//
//   Watch Variables:
//
//         Voltage1   Last 10 ADCRESULT0 values
//         Voltage2   Last 10 ADCRESULT1 values
//         ConversionCountCurrent result number 0-9
//         LoopCount      Idle loop counter
//
//
//###########################################################################
// $TI Release: 2802x Header Files V1.00 $
// $Release Date: November 10, 2008 $
//###########################################################################

#include "DSP28x_Project.h"   // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
interrupt void adc_isr(void);
void Adc_Config(void);


// Global variables used in this example:
Uint16 LoopCount;
Uint16 ConversionCount;
Uint16 Voltage1;
Uint16 Voltage2;


main()
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2803x_SysCtrl.c file.
   InitSysCtrl();


// Step 2. Initialize GPIO:
// This example function is found in the DSP2802x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();// Skipped for this example

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize the 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 DSP2802x_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 DSP2802x_DefaultIsr.c.
// This function is found in DSP2802x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;// This is needed to write to EALLOW protected register
   PieVectTable.ADCINT1 = &adc_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2802x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   InitAdc();// For this example, init the ADC

// Step 5. User specific code, enable interrupts:

// Enable ADCINT1 in PIE
   PieCtrlRegs.PIEIER1.bit.INTx1 = 1;        // Enable INT 1.1 in the PIE
   IER |= M_INT1;                                                 // Enable CPU Interrupt 1
   EINT;                                                          // Enable Global interrupt INTM
   ERTM;                                                          // Enable Global realtime interrupt DBGM

   LoopCount = 0;
   ConversionCount = 0;

// Configure ADC
        EALLOW;
        AdcRegs.ADCCTL1.bit.INTPULSEPOS        = 1;        //ADCINT1 trips after AdcResults latch
        AdcRegs.INTSEL1N2.bit.INT1E   = 1;        //Enabled ADCINT1
        AdcRegs.INTSEL1N2.bit.INT1CONT= 0;        //Disable ADCINT1 Continuous mode
        AdcRegs.INTSEL1N2.bit.INT1SEL        = 1;        //setup EOC1 to trigger ADCINT1 to fire
        AdcRegs.ADCSOC0CTL.bit.CHSEL         = 4;        //set SOC0 channel select to ADCINA4
        AdcRegs.ADCSOC1CTL.bit.CHSEL         = 2;        //set SOC1 channel select to ADCINA2
        AdcRegs.ADCSOC0CTL.bit.TRIGSEL         = 5;        //set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
        AdcRegs.ADCSOC1CTL.bit.TRIGSEL         = 5;        //set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
        AdcRegs.ADCSOC0CTL.bit.ACQPS         = 6;        //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
        AdcRegs.ADCSOC1CTL.bit.ACQPS         = 6;        //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
        EDIS;

// Assumes ePWM1 clock is already enabled in InitSysCtrl();
   EPwm1Regs.ETSEL.bit.SOCAEN        = 1;                // Enable SOC on A group
   EPwm1Regs.ETSEL.bit.SOCASEL        = 4;                // Select SOC from from CPMA on upcount
   EPwm1Regs.ETPS.bit.SOCAPRD         = 1;                // Generate pulse on 1st event
   EPwm1Regs.CMPA.half.CMPA         = 0x0080;        // Set compare A value
   EPwm1Regs.TBPRD                                 = 0xFFFF;        // Set period for ePWM1
   EPwm1Regs.TBCTL.bit.CTRMODE         = 0;                // count up and start

// Wait for ADC interrupt
   for(;;)
   {
      LoopCount++;
   }

}


interrupt voidadc_isr(void)
{

Voltage1 = AdcResult.ADCRESULT0;
Voltage2 = AdcResult.ADCRESULT1;

// If 20 conversions have been logged, start over
if(ConversionCount == 9)
{
   ConversionCount = 0;
}
else ConversionCount++;

AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;                //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   // Acknowledge interrupt to PIE

return;
}

mvp1984 发表于 2010-3-30 21:44:29

1.pwm波能控制步进电机吗?我看了一本书的例子里面用的是cputimer0中断实现的。具体的不是很明白,还有方向控制。请楼主指导,谢谢!!!我刚开始学dsp,问的问题可能比较小白,还望见谅!


2.GpioDataRegs.GPADAT.all=0x009c是什么意思?后面的数字我随便打的。
书上说GPADAT寄存器是可读/写寄存器。
具体的我没看明白什么意思。请楼主指导,谢谢!!!
页: 1 [2] 3 4
查看完整版本: TMS320F28XX问题讨论贴,我会尽量回答大家提出的问题