云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > dsp30代码

dsp30代码

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 11:07:32

;===================================================== ; 等效的 C代码 ;{

; register short Pos, Delta; ;

; Pos = POSCNT; ;

; Delta = Pos - EncoderParm.iPrevCnt; ; EncoderParm.iPrevCnt = Pos; ;

; if( iDelta >= 0 ) ;{

; // Delta > 0因为 ; // 1) vel > 0或

; // 2) Vel < 0且编码器计数值出现翻转返回。 ;

; if( Delta >= EncoderParm.iCntsPerRev/2 ) ;{

; // Delta >= EncoderParm.iCntsPerRev/2 => 负转速,出现翻转返回 ;

; Delta -= EncoderParm.iCntsPerRev; ;} ;} ; else ;{

; // Delta < 0因为 ; // 1) vel < 0或

; // 2) Vel > 0并出现翻转返回 ;;

; if( Delta < -EncoderParm.iCntsPerRev/2 ) ;{

; // Delta < -EncoderParm.iCntsPerRev/2 => 正转速,出现翻转返回 ;

; Delta += EncoderParm.iCntsPerRev; ;} ;} ;

; EncoderParm.iAccumCnt += Delta; ;

; EncoderParm.iVelCntDwn--; ; if(EncoderParm.iVelCntDwn) ; return; ;

; iVelCntDwn = iIrpPerCalc;

; qVelMech = qKvel * iAccumCnt * 2^Nvel; ; EncoderParm.iAccumCnt = 0; ;}

;=================== 代码 ===================== ; CalcVelIrp的寄存器使用

.equ PosW, w0 ; 当前位置: POSCNT .equ WorkW, w4 ; 工作寄存器

.equ DeltaW, w6 ; NewCnt - PrevCnt .global _CalcVelIrp .global CalcVelIrp _CalcVelIrp: CalcVelIrp:

;; 保存寄存器内容 push w0 push w4 push w6

;; Pos = uTestPos; .ifdef SIMU

mov.w _uTestPos,PosW ; 编码器值 ?? .else

mov.w POSCNT,PosW ; 编码器值 .endif

mov.w _EncoderParm+Encod_iPrevCnt,WorkW

;; 用新的 cnt更新前一个 cnt。

mov.w PosW,_EncoderParm+Encod_iPrevCnt

;; 计算 Delta = New - Prev sub.w PosW,WorkW,DeltaW bra N,jEncoder5 ; Delta < 0

;; Delta > 0因为

;; 1) vel > 0或

搜索更多关于: dsp30代码 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

;===================================================== ; 等效的 C代码 ;{ ; register short Pos, Delta; ; ; Pos = POSCNT; ; ; Delta = Pos - EncoderParm.iPrevCnt; ; EncoderParm.iPrevCnt = Pos; ; ; if( iDelta >= 0 ) ;{ ; // Delta > 0因为 ; // 1) vel > 0或 ; // 2) Vel < 0且编码器计数值出现翻转返回。 ; ; if( Delta >= EncoderParm.iCntsPerRev/2

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com