PIC24 Support Libraries
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
chap9
change_wakeup_noint.c
Go to the documentation of this file.
1
/*
2
* "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
3
* All rights reserved.
4
* (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
5
* (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
6
* (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
7
*
8
* Permission to use, copy, modify, and distribute this software and its
9
* documentation for any purpose, without fee, and without written agreement is
10
* hereby granted, provided that the above copyright notice, the following
11
* two paragraphs and the authors appear in all copies of this software.
12
*
13
* IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
14
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
15
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
16
* HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17
*
18
* THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21
* ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
22
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
23
*
24
* Please maintain this header in its entirety when copying/modifying
25
* these files.
26
*
27
*
28
*/
29
30
#include "
pic24_all.h
"
31
32
/** \file
33
Demonstrates the use of change notification interrupt
34
to wake from Sleep mode when the CN priority is 0.
35
This does not use an ISR.
36
The datasheet says this should work, but it does not
37
work on the PIC24HJ32GP202 it seems.
38
*/
39
40
41
/// Switch1 configuration: place on RB13.
42
inline
void
CONFIG_SW1
() {
43
CONFIG_RB13_AS_DIG_INPUT();
//use RB13 for switch input
44
ENABLE_RB13_PULLUP();
//enable the pullup
45
ENABLE_RB13_CN_INTERRUPT();
//CN13IE = 1
46
DELAY_US
(1);
// Wait for pullup
47
}
48
49
int
main
(
void
) {
50
configBasic
(HELLO_MSG);
51
/** Configure the switch ***********/
52
CONFIG_SW1
();
//enables individual CN interrupt also
53
/** Configure Change Notification general interrupt */
54
_CNIF = 0;
//Clear the interrupt flag
55
_CNIP = 0;
//Set priority 0, no ISR
56
_CNIE = 1;
//enable the Change Notification general interrupt
57
while
(1) {
58
outString
(
"Entering Sleep mode, press button to wake.\n"
);
59
// Finish sending characters before sleeping
60
WAIT_UNTIL_TRANSMIT_COMPLETE_UART1
();
61
SLEEP
();
//macro for asm("pwrsav #0")
62
_CNIF = 0;
//No ISR, so need to clear _CNIF here.
63
}
64
// End program
65
return
0;
66
}
Generated by
1.8.4