These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Committer:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Revision:
0:bf7b9fba3924

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frank26080115 0:bf7b9fba3924 1 /***********************************************************************//**
frank26080115 0:bf7b9fba3924 2 * @file wdt_reset_test.c
frank26080115 0:bf7b9fba3924 3 * @purpose This example describes how to use WDT in reset mode
frank26080115 0:bf7b9fba3924 4 * @version 2.0
frank26080115 0:bf7b9fba3924 5 * @date 21. May. 2010
frank26080115 0:bf7b9fba3924 6 * @author NXP MCU SW Application Team
frank26080115 0:bf7b9fba3924 7 *---------------------------------------------------------------------
frank26080115 0:bf7b9fba3924 8 * Software that is described herein is for illustrative purposes only
frank26080115 0:bf7b9fba3924 9 * which provides customers with programming information regarding the
frank26080115 0:bf7b9fba3924 10 * products. This software is supplied "AS IS" without any warranties.
frank26080115 0:bf7b9fba3924 11 * NXP Semiconductors assumes no responsibility or liability for the
frank26080115 0:bf7b9fba3924 12 * use of the software, conveys no license or title under any patent,
frank26080115 0:bf7b9fba3924 13 * copyright, or mask work right to the product. NXP Semiconductors
frank26080115 0:bf7b9fba3924 14 * reserves the right to make changes in the software without
frank26080115 0:bf7b9fba3924 15 * notification. NXP Semiconductors also make no representation or
frank26080115 0:bf7b9fba3924 16 * warranty that such application will be suitable for the specified
frank26080115 0:bf7b9fba3924 17 * use without further testing or modification.
frank26080115 0:bf7b9fba3924 18 **********************************************************************/
frank26080115 0:bf7b9fba3924 19 #include "lpc17xx_wdt.h"
frank26080115 0:bf7b9fba3924 20 #include "lpc17xx_libcfg.h"
frank26080115 0:bf7b9fba3924 21 #include "lpc17xx_pinsel.h"
frank26080115 0:bf7b9fba3924 22 #include "debug_frmwrk.h"
frank26080115 0:bf7b9fba3924 23 #include "lpc17xx_gpio.h"
frank26080115 0:bf7b9fba3924 24
frank26080115 0:bf7b9fba3924 25 /* Example group ----------------------------------------------------------- */
frank26080115 0:bf7b9fba3924 26 /** @defgroup WDT_RESET RESET
frank26080115 0:bf7b9fba3924 27 * @ingroup WDT_Examples
frank26080115 0:bf7b9fba3924 28 * @{
frank26080115 0:bf7b9fba3924 29 */
frank26080115 0:bf7b9fba3924 30
frank26080115 0:bf7b9fba3924 31 /************************** PRIVATE DEFINITIONS *************************/
frank26080115 0:bf7b9fba3924 32 //#define MCB_LPC_1768
frank26080115 0:bf7b9fba3924 33 #define IAR_LPC_1768
frank26080115 0:bf7b9fba3924 34
frank26080115 0:bf7b9fba3924 35 //Watchodog time out in 5 seconds
frank26080115 0:bf7b9fba3924 36 #define WDT_TIMEOUT 5000000
frank26080115 0:bf7b9fba3924 37
frank26080115 0:bf7b9fba3924 38
frank26080115 0:bf7b9fba3924 39 /************************** PRIVATE VARIABLES *************************/
frank26080115 0:bf7b9fba3924 40 uint8_t menu1[] =
frank26080115 0:bf7b9fba3924 41 "********************************************************************************\n\r"
frank26080115 0:bf7b9fba3924 42 "This Welcome Screen below will executive after reset event \n\r"
frank26080115 0:bf7b9fba3924 43 "Hello NXP Semiconductors \n\r"
frank26080115 0:bf7b9fba3924 44 " Watch dog timer reset when timeout demo \n\r"
frank26080115 0:bf7b9fba3924 45 "\t - MCU: LPC17xx \n\r"
frank26080115 0:bf7b9fba3924 46 "\t - Core: Cortex M3 \n\r"
frank26080115 0:bf7b9fba3924 47 "\t - Communicate via: UART0 - 115200 bps \n\r"
frank26080115 0:bf7b9fba3924 48 " Use WDT with Internal RC OSC, reset mode, timeout = 5 seconds \n\r"
frank26080115 0:bf7b9fba3924 49 " To reset MCU when time out. After reset, program will determine what cause of "
frank26080115 0:bf7b9fba3924 50 " last reset time (external reset or WDT time-out)\n\r"
frank26080115 0:bf7b9fba3924 51 "********************************************************************************\n\r";
frank26080115 0:bf7b9fba3924 52 uint8_t info1[] = "Last MCU reset caused by WDT TimeOut!\n\r";
frank26080115 0:bf7b9fba3924 53 uint8_t info2[] = "Last MCU reset caused by External!\n\r";
frank26080115 0:bf7b9fba3924 54
frank26080115 0:bf7b9fba3924 55 /*-------------------------MAIN FUNCTION------------------------------*/
frank26080115 0:bf7b9fba3924 56 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 57 * @brief c_entry: Main WDT program body
frank26080115 0:bf7b9fba3924 58 * @param[in] None
frank26080115 0:bf7b9fba3924 59 * @return int
frank26080115 0:bf7b9fba3924 60 **********************************************************************/
frank26080115 0:bf7b9fba3924 61 int c_entry(void)
frank26080115 0:bf7b9fba3924 62 {
frank26080115 0:bf7b9fba3924 63 /* Initialize debug via UART0
frank26080115 0:bf7b9fba3924 64 * – 115200bps
frank26080115 0:bf7b9fba3924 65 * – 8 data bit
frank26080115 0:bf7b9fba3924 66 * – No parity
frank26080115 0:bf7b9fba3924 67 * – 1 stop bit
frank26080115 0:bf7b9fba3924 68 * – No flow control
frank26080115 0:bf7b9fba3924 69 */
frank26080115 0:bf7b9fba3924 70 debug_frmwrk_init();
frank26080115 0:bf7b9fba3924 71
frank26080115 0:bf7b9fba3924 72 // print welcome screen
frank26080115 0:bf7b9fba3924 73 _DBG(menu1);
frank26080115 0:bf7b9fba3924 74
frank26080115 0:bf7b9fba3924 75 // Read back TimeOut flag to determine previous timeout reset
frank26080115 0:bf7b9fba3924 76 if (WDT_ReadTimeOutFlag()){
frank26080115 0:bf7b9fba3924 77 _DBG_(info1);
frank26080115 0:bf7b9fba3924 78 // Clear WDT TimeOut
frank26080115 0:bf7b9fba3924 79 WDT_ClrTimeOutFlag();
frank26080115 0:bf7b9fba3924 80 } else{
frank26080115 0:bf7b9fba3924 81 _DBG_(info2);
frank26080115 0:bf7b9fba3924 82 }
frank26080115 0:bf7b9fba3924 83
frank26080115 0:bf7b9fba3924 84 // Initialize WDT, IRC OSC, interrupt mode, timeout = 5000000us = 5s
frank26080115 0:bf7b9fba3924 85 WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_RESET);
frank26080115 0:bf7b9fba3924 86 // Start watchdog with timeout given
frank26080115 0:bf7b9fba3924 87 WDT_Start(WDT_TIMEOUT);
frank26080115 0:bf7b9fba3924 88
frank26080115 0:bf7b9fba3924 89 //infinite loop to wait chip reset from WDT
frank26080115 0:bf7b9fba3924 90 while(1);
frank26080115 0:bf7b9fba3924 91
frank26080115 0:bf7b9fba3924 92 return 0;
frank26080115 0:bf7b9fba3924 93 }
frank26080115 0:bf7b9fba3924 94
frank26080115 0:bf7b9fba3924 95 /* Support required entry point for other toolchain */
frank26080115 0:bf7b9fba3924 96 int main (void)
frank26080115 0:bf7b9fba3924 97 {
frank26080115 0:bf7b9fba3924 98 return c_entry();
frank26080115 0:bf7b9fba3924 99 }
frank26080115 0:bf7b9fba3924 100 #ifdef DEBUG
frank26080115 0:bf7b9fba3924 101 /*******************************************************************************
frank26080115 0:bf7b9fba3924 102 * @brief Reports the name of the source file and the source line number
frank26080115 0:bf7b9fba3924 103 * where the CHECK_PARAM error has occurred.
frank26080115 0:bf7b9fba3924 104 * @param[in] file Pointer to the source file name
frank26080115 0:bf7b9fba3924 105 * @param[in] line assert_param error line source number
frank26080115 0:bf7b9fba3924 106 * @return None
frank26080115 0:bf7b9fba3924 107 *******************************************************************************/
frank26080115 0:bf7b9fba3924 108 void check_failed(uint8_t *file, uint32_t line)
frank26080115 0:bf7b9fba3924 109 {
frank26080115 0:bf7b9fba3924 110 /* User can add his own implementation to report the file name and line number,
frank26080115 0:bf7b9fba3924 111 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
frank26080115 0:bf7b9fba3924 112
frank26080115 0:bf7b9fba3924 113 /* Infinite loop */
frank26080115 0:bf7b9fba3924 114 while(1);
frank26080115 0:bf7b9fba3924 115 }
frank26080115 0:bf7b9fba3924 116 #endif
frank26080115 0:bf7b9fba3924 117
frank26080115 0:bf7b9fba3924 118 /*
frank26080115 0:bf7b9fba3924 119 * @}
frank26080115 0:bf7b9fba3924 120 */