📄 wd.c
字号:
/*************************************************************************
*
* Used with ICCARM and AARM.
*
* (c) Copyright IAR Systems 2007
*
* File name : wd.c
* Description : Main file
*
* History :
* 1. Date : August 2, 2007
* Author : Stanimir Bonev
* Description : Create
*
* This example project shows how to use the IAR Embedded Workbench for ARM
* to develop code for the Samsung-S3F4A0K evaluation board. It shows
* basic use of WDT.
* The example flashing LED DS4 (P1.9) when WDT pended and cleared
*
* $Revision: 18083 $
**************************************************************************/
#include <samsung\ios3f4a0k.h>
#include "arm_comm.h"
#include "board.h"
/*************************************************************************
* Function Name: main
* Parameters: none
* Return: none
*
* Description: Main
*
*************************************************************************/
void main (void)
{
// WDT init
// LFCLK = 250kHz (OSC/(MDIV*VFDIV))
// WD Period - 1s = WDPDIV * (PCV[15:0]+1)/LFCLK
// WDPDIV = /8; PCV = 31249
WD_MR = (0x37UL << 24) | ((31250-1) << 8) | 2;
// Set Pending Windows period 0.5 s
// PWL = 15625-1, Restart allowed only within pending window
WD_PWR = (0x91UL << 24) | ((15625-1)<<8) | 1;
// Clear flags
WD_CSR = 3;
// WD restart
WD_CR = 0xC071;
// WD enable
WD_OMR = (0x234UL << 4) | 1;
// Enable PIO block
// PIO Software Reset
PIO1_CR = 1;
// P1.9 is PIO
PIO1_PER = 1 << 9;
// Enable Push-pull
PIO1_MDDR = 1 << 9;
// Set P1.9 to output
PIO1_OER = 1 << 9;
// Clear output (LED off)
PIO1_CODR = 1 << 9;
while(1)
{
if(WD_SR_bit.WDPEND)
{
// Clear flags
WD_CSR = 3;
// WD restart
WD_CR = 0xC071;
// toggle P1.9
PIO1_WODR = PIO1_ODSR ^ (1<<9);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -