日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

DSP 中的看门狗

發布時間:2024/4/24 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 DSP 中的看门狗 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

DSP?中的看門狗

? (2012-11-20 13:43:01)

標簽:?

?

dsp

?

看門狗

分類:?DSP

看門狗電路的應用,使單片機可以在無人狀態下實現連續工作,其工作原理是:看門狗芯片和單片機的一個I/O引腳相連,該I/O引腳通過程序控制它定時地往看門狗的這個引腳上送入高電平(或低電平),這一程序語句是分散地放在單片機其他控制語句中間的,一旦單片機由于干擾造成程序跑飛后而陷入某一程序段?進入死循環狀態時,寫看門狗引腳的程序便不能被執行,這個時候,看門狗電路就會由于得不到單片機送來的信號,便在它和單片機復位引腳相連的引腳上送出一個復位信號,使單片機發生復位,即程序從程序存儲器的起始位置開始執行,這樣便實現了單片機的自動復位。

總結就是 喂狗狗不叫,沒人喂了狗就要叫CPU復位

看門狗的機理:

??主要核心是一個定時器,當定時器時間到時復位

??正常運行程序過程中每次在看門狗的定時器時間到之前重啟看門狗定時器

TMS320F2833X?看門狗的組成

?

1.定時器(計數器) WD Counter?

??2.看門狗重啟管理器(WD Reset Register)

??3.看門狗時鐘發生器。

??4.看門狗狀態位



?

看門狗時鐘發生器:

??WDCLK = CLKOUT/512,HALT時停止

6-bits預定標選擇:WDCLK再分頻后送給看門狗定時器。WDPS2~0 in WDCR



?

看門狗控制寄存器:WDCR

?
?

?

?

WDFLAG: 0-未發生復位,1-發生復位

WDDIS: 0-使能看門狗,1-禁止看門狗

WDCHK2~0: 101   系統正常運行

      其他值  復位

?WDCR = 0X 28 ?(00 101 000) 使能看門狗

?

?

看門狗定時器(計數器) WDCNTR:

????低8位為計數器,當低8位溢出時,產生一個復位信號。此寄存器為只讀的。

看門狗重啟管理器?WDKEY:

????低8位為寄存器,只有先寫入55h后寫入AAh后重啟看門狗計數器。

????不是此順序寫入55h或AAh,則無效。

????寫入其他數值時產生復位信號。

?

?

使用時,,首先寫SCSR 寄存器 。System Control and Status Register

?

在 文檔中 TMS320x2833x, 2823x System Control and?Interrupts 找到


?

?


?

?

?

?

?

#include "DSP2833x_Device.h" ????// Headerfile Include File

#include "DSP2833x_Examples.h" ??// Examples Include File

?

// Prototype statements for functions found within this file.

interrupt void wakeint_isr(void);

?

// Global variables for this example

Uint32 WakeCount;

Uint32 LoopCount;

?

void main(void)

{

?

???InitSysCtrl();

?

// Disable CPU interrupts?

???DINT;

?

???InitPieCtrl();

?

// Disable CPU interrupts and clear all CPU interrupt flags:

???IER = 0x0000;

???IFR = 0x0000;

?

?

???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.WAKEINT = &wakeint_isr;

???EDIS; ??// This is needed to disable write to EALLOW protected registers

?

?

?

// Clear the counters

???WakeCount = 0; // Count interrupts

???LoopCount = 0; // Count times through idle loop

?

// Connect the watchdog to the WAKEINT interrupt of the PIE

// Write to the whole SCSR register to avoid clearing WDOVERRIDE bit

???EALLOW;

???SysCtrlRegs.SCSR = BIT1; ?????//WDENINT寫1,使能watchdog 中斷

???EDIS;

?

// Enable WAKEINT in the PIE: Group 1 interrupt 8

// Enable INT1 which is connected to WAKEINT:

???PieCtrlRegs.PIECTRL.bit.ENPIE = 1; ??// Enable the PIE block

???PieCtrlRegs.PIEIER1.bit.INTx8 = 1; ??// Enable PIE Gropu 1 INT8 ??WAKEINT中斷 ?

???IER |= M_INT1; ??????????????????????// Enable CPU int1

???EINT; ???????????????????????????????// Enable Global Interrupts

?

// Reset the watchdog counter

??ServiceDog();

??????

// Enable the watchdog

???EALLOW;

???SysCtrlRegs.WDCR = 0x0028; ??

???EDIS;

???

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

???for(;;)

???{

??????LoopCount++;

???

????

????ServiceDog();

???}

?

?

}

?

?

interrupt void wakeint_isr(void)

{

WakeCount++;

?

// Acknowledge this interrupt to get more from group 1

PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

}

?

?

void ServiceDog(void)

{

????EALLOW;

????SysCtrlRegs.WDKEY = 0x0055;

????SysCtrlRegs.WDKEY = 0x00AA;

????EDIS;

}

?


?

?

本實驗中 WakeCount 是進入wakeint_isr 中斷一次以后加1.

?

在程序段

?

for(;;)

???{

??????LoopCount++;

???

??????// Uncomment ServiceDog to just loop here

??????// Comment ServiceDog to take the WAKEINT instead

????ServiceDog();

???}

中不斷地喂狗,,主程序進不了中斷,?WakeCount不會+1,一直為零。

?

如果把這段程序注釋掉。就會不停進入中斷。WakeCount就會一直增加。

總結

以上是生活随笔為你收集整理的DSP 中的看门狗的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。