This is a low power example of the MAX1473 RF Receiver using the MAX32630FTHR.
Dependencies: MAX30208 mbed-dev max32630fthr USBDevice
main.cpp@4:7320d2a40b92, 2020-09-04 (annotated)
- Committer:
- tlyp
- Date:
- Fri Sep 04 20:45:01 2020 +0000
- Revision:
- 4:7320d2a40b92
- Parent:
- 3:4af4942a59f2
Added Comments for clearer execution
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tlyp | 2:e4fcc385e824 | 1 | /******************************************************************************* |
tlyp | 2:e4fcc385e824 | 2 | * Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved. |
tlyp | 2:e4fcc385e824 | 3 | * |
tlyp | 2:e4fcc385e824 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
tlyp | 2:e4fcc385e824 | 5 | * copy of this software and associated documentation files (the "Software"), |
tlyp | 2:e4fcc385e824 | 6 | * to deal in the Software without restriction, including without limitation |
tlyp | 2:e4fcc385e824 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
tlyp | 2:e4fcc385e824 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
tlyp | 2:e4fcc385e824 | 9 | * Software is furnished to do so, subject to the following conditions: |
tlyp | 2:e4fcc385e824 | 10 | * |
tlyp | 2:e4fcc385e824 | 11 | * The above copyright notice and this permission notice shall be included |
tlyp | 2:e4fcc385e824 | 12 | * in all copies or substantial portions of the Software. |
tlyp | 2:e4fcc385e824 | 13 | * |
tlyp | 2:e4fcc385e824 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
tlyp | 2:e4fcc385e824 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
tlyp | 2:e4fcc385e824 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
tlyp | 2:e4fcc385e824 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
tlyp | 2:e4fcc385e824 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
tlyp | 2:e4fcc385e824 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
tlyp | 2:e4fcc385e824 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
tlyp | 2:e4fcc385e824 | 21 | * |
tlyp | 2:e4fcc385e824 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
tlyp | 2:e4fcc385e824 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
tlyp | 2:e4fcc385e824 | 24 | * Products, Inc. Branding Policy. |
tlyp | 2:e4fcc385e824 | 25 | * |
tlyp | 2:e4fcc385e824 | 26 | * The mere transfer of this software does not imply any licenses |
tlyp | 2:e4fcc385e824 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
tlyp | 2:e4fcc385e824 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
tlyp | 2:e4fcc385e824 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
tlyp | 2:e4fcc385e824 | 30 | * ownership rights. |
tlyp | 2:e4fcc385e824 | 31 | ******************************************************************************* |
tlyp | 2:e4fcc385e824 | 32 | This is code for the MAX1473 RF Receiver circuit. This program will capture, |
tlyp | 2:e4fcc385e824 | 33 | translate, and unencrypt messages received using the ForwardErrCorr.h format. |
tlyp | 2:e4fcc385e824 | 34 | The example uses MAX30208 temperature data as an example. The MAX1473 will turn |
tlyp | 2:e4fcc385e824 | 35 | on for 5ms every 500ms to check for data. If there is data to be read, the reciever |
tlyp | 2:e4fcc385e824 | 36 | will remain on to listen for a full packet. If there is no data, it will return to |
tlyp | 2:e4fcc385e824 | 37 | sleep mode for another 500ms. |
tlyp | 2:e4fcc385e824 | 38 | |
tlyp | 2:e4fcc385e824 | 39 | Hardware Setup and connections: |
tlyp | 2:e4fcc385e824 | 40 | |
tlyp | 2:e4fcc385e824 | 41 | MAX32630FTHR-> MAX1473 Ev-Kit |
tlyp | 2:e4fcc385e824 | 42 | |
tlyp | 2:e4fcc385e824 | 43 | 3.3V -> VDD |
tlyp | 2:e4fcc385e824 | 44 | GND -> GND |
tlyp | 2:e4fcc385e824 | 45 | P3_0 -> DATA_OUT |
tlyp | 2:e4fcc385e824 | 46 | P5_6 -> DATA_OUT |
tlyp | 2:e4fcc385e824 | 47 | P5_1 -> ENABLE |
tlyp | 2:e4fcc385e824 | 48 | 1.8V -> 200KOhm -> TP2 |
tlyp | 2:e4fcc385e824 | 49 | |
tlyp | 2:e4fcc385e824 | 50 | ******************************************************************************* |
tlyp | 2:e4fcc385e824 | 51 | */ |
tlyp | 2:e4fcc385e824 | 52 | |
MI | 0:41ed595f83f5 | 53 | #include "mbed.h" |
MI | 0:41ed595f83f5 | 54 | #include "max32630fthr.h" |
MI | 0:41ed595f83f5 | 55 | #include "mxc_config.h" |
MI | 0:41ed595f83f5 | 56 | #include "lp.h" |
MI | 0:41ed595f83f5 | 57 | #include "gpio.h" |
MI | 1:8834bc22c2e7 | 58 | #include "rtc.h" |
MI | 1:8834bc22c2e7 | 59 | #include "MAX14690.h" |
tlyp | 2:e4fcc385e824 | 60 | #include "USBSerial.h" |
tlyp | 2:e4fcc385e824 | 61 | #include "MAX30208.h" |
tlyp | 2:e4fcc385e824 | 62 | #include "ForwardErrCorr.h" |
tlyp | 2:e4fcc385e824 | 63 | |
tlyp | 2:e4fcc385e824 | 64 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
tlyp | 2:e4fcc385e824 | 65 | |
tlyp | 2:e4fcc385e824 | 66 | I2C i2c(P3_4, P3_5); //sda,scl |
tlyp | 2:e4fcc385e824 | 67 | |
tlyp | 2:e4fcc385e824 | 68 | RawSerial uart(P3_1,P3_0); //tx,rx |
tlyp | 2:e4fcc385e824 | 69 | MAX30208 TempSensor(i2c, 0x50); //Constructor, takes 7-bit slave adrs |
tlyp | 2:e4fcc385e824 | 70 | |
tlyp | 2:e4fcc385e824 | 71 | char TransTable[] = {0x1F,0x18,0x06,0x01}; //Used to translate data for FEC -- Make sure it is identical to transmitter |
tlyp | 2:e4fcc385e824 | 72 | #define SymmetricKey "RfIsCoOl" //Set Symmetric Key here -- Make sure it is identical to transmitter |
tlyp | 2:e4fcc385e824 | 73 | Translator transRx(SymmetricKey, TransTable); |
tlyp | 2:e4fcc385e824 | 74 | |
tlyp | 2:e4fcc385e824 | 75 | USBSerial microUSB; //Micro USB Connection for printing to Serial Monitor |
MI | 0:41ed595f83f5 | 76 | |
MI | 0:41ed595f83f5 | 77 | DigitalOut rLED(LED1); |
MI | 0:41ed595f83f5 | 78 | DigitalOut gLED(LED2); |
MI | 0:41ed595f83f5 | 79 | DigitalOut bLED(LED3); |
MI | 0:41ed595f83f5 | 80 | |
tlyp | 2:e4fcc385e824 | 81 | InterruptIn CheckData(P5_6); //Interrupt pin for detecting incoming messages |
tlyp | 2:e4fcc385e824 | 82 | |
tlyp | 4:7320d2a40b92 | 83 | DigitalIn sw2(SW1); //Used on start-up to stay in active mode for re-programming |
tlyp | 2:e4fcc385e824 | 84 | DigitalOut RXEnable(P5_1); //Used to Enable Reciever |
tlyp | 2:e4fcc385e824 | 85 | |
tlyp | 2:e4fcc385e824 | 86 | |
tlyp | 2:e4fcc385e824 | 87 | volatile bool reading; //Check interrupt to dtermin if there is incoming data |
tlyp | 2:e4fcc385e824 | 88 | volatile char dataIn[50]; //Hold incoming message |
tlyp | 2:e4fcc385e824 | 89 | volatile int datacounter; //Count the incoming data |
tlyp | 2:e4fcc385e824 | 90 | |
MI | 0:41ed595f83f5 | 91 | |
MI | 0:41ed595f83f5 | 92 | // ***************************************************************************** |
tlyp | 2:e4fcc385e824 | 93 | /** |
tlyp | 2:e4fcc385e824 | 94 | * @brief Setup RTC with scaler set to 1 tick per ~ 1 ms |
tlyp | 2:e4fcc385e824 | 95 | */ |
MI | 1:8834bc22c2e7 | 96 | void RTC_Setup() |
MI | 0:41ed595f83f5 | 97 | { |
tlyp | 2:e4fcc385e824 | 98 | rtc_cfg_t RTCconfig; //Declare RTC Object |
tlyp | 2:e4fcc385e824 | 99 | RTCconfig.prescaler = RTC_PRESCALE_DIV_2_2; //~1ms per RTC tick |
tlyp | 2:e4fcc385e824 | 100 | RTCconfig.prescalerMask = RTC_PRESCALE_DIV_2_2; //~1ms per RTC tick(0.97656ms) |
MI | 1:8834bc22c2e7 | 101 | RTCconfig.snoozeCount = 0; |
MI | 1:8834bc22c2e7 | 102 | RTCconfig.snoozeMode = RTC_SNOOZE_DISABLE; |
MI | 0:41ed595f83f5 | 103 | |
tlyp | 2:e4fcc385e824 | 104 | RTC_Init(&RTCconfig); //initialize RTC with desired configuration |
tlyp | 2:e4fcc385e824 | 105 | |
tlyp | 2:e4fcc385e824 | 106 | RTC_Start(); //Begin RTC |
tlyp | 2:e4fcc385e824 | 107 | } |
MI | 0:41ed595f83f5 | 108 | |
tlyp | 2:e4fcc385e824 | 109 | //***************************************************************************** |
tlyp | 2:e4fcc385e824 | 110 | /** |
tlyp | 2:e4fcc385e824 | 111 | * @brief Serial Intterupt to read incoming data from Reciever |
tlyp | 2:e4fcc385e824 | 112 | */ |
tlyp | 2:e4fcc385e824 | 113 | void SerialCallback(){ |
tlyp | 2:e4fcc385e824 | 114 | wait_ms(1); |
tlyp | 2:e4fcc385e824 | 115 | if (datacounter < 50){ |
tlyp | 2:e4fcc385e824 | 116 | while(uart.readable() && datacounter <= 50){ |
tlyp | 2:e4fcc385e824 | 117 | dataIn[datacounter] = uart.getc(); |
tlyp | 2:e4fcc385e824 | 118 | datacounter++; |
tlyp | 2:e4fcc385e824 | 119 | } |
tlyp | 2:e4fcc385e824 | 120 | } |
MI | 0:41ed595f83f5 | 121 | } |
MI | 0:41ed595f83f5 | 122 | |
tlyp | 2:e4fcc385e824 | 123 | //***************************************************************************** |
tlyp | 2:e4fcc385e824 | 124 | /** |
tlyp | 2:e4fcc385e824 | 125 | * @brief Shorten input data array to only one full transmission (eliminate excess and partial transactions) |
tlyp | 2:e4fcc385e824 | 126 | * @param start - array position that contatins starting character ('b') |
tlyp | 2:e4fcc385e824 | 127 | * @param input - Character array that holds the recorded data |
tlyp | 2:e4fcc385e824 | 128 | * @param output - Output array that holds one packet of data |
tlyp | 2:e4fcc385e824 | 129 | * @return 0 on success, 1 if the end character cannot be found |
tlyp | 2:e4fcc385e824 | 130 | */ |
tlyp | 2:e4fcc385e824 | 131 | int buildArray(int start, volatile char *input,char *output){ |
tlyp | 2:e4fcc385e824 | 132 | int i = start+1; |
tlyp | 2:e4fcc385e824 | 133 | int k = 0; |
tlyp | 2:e4fcc385e824 | 134 | while(input[i] != 'c'){ |
tlyp | 2:e4fcc385e824 | 135 | output[k] = input[i]; |
tlyp | 2:e4fcc385e824 | 136 | i++; |
tlyp | 2:e4fcc385e824 | 137 | k++; |
tlyp | 2:e4fcc385e824 | 138 | if (i > 50){ |
tlyp | 2:e4fcc385e824 | 139 | return (1); |
tlyp | 2:e4fcc385e824 | 140 | } |
tlyp | 2:e4fcc385e824 | 141 | } |
tlyp | 2:e4fcc385e824 | 142 | return(0); |
tlyp | 2:e4fcc385e824 | 143 | } |
tlyp | 2:e4fcc385e824 | 144 | |
tlyp | 2:e4fcc385e824 | 145 | //***************************************************************************** |
tlyp | 2:e4fcc385e824 | 146 | /** |
tlyp | 2:e4fcc385e824 | 147 | * @brief Intterupt for checking incoming data. When triggered, intterupt is added for reading incoming data, and flag is set for incoming data |
tlyp | 2:e4fcc385e824 | 148 | */ |
tlyp | 2:e4fcc385e824 | 149 | void CheckUart(){ |
tlyp | 2:e4fcc385e824 | 150 | uart.attach(&SerialCallback); |
tlyp | 2:e4fcc385e824 | 151 | CheckData.disable_irq(); |
tlyp | 2:e4fcc385e824 | 152 | reading = 1; |
tlyp | 2:e4fcc385e824 | 153 | } |
tlyp | 2:e4fcc385e824 | 154 | |
tlyp | 2:e4fcc385e824 | 155 | //****************************************************************************** |
tlyp | 2:e4fcc385e824 | 156 | |
MI | 0:41ed595f83f5 | 157 | int main(void) |
MI | 0:41ed595f83f5 | 158 | { |
tlyp | 4:7320d2a40b92 | 159 | //configure PMIC |
MI | 1:8834bc22c2e7 | 160 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
tlyp | 4:7320d2a40b92 | 161 | |
tlyp | 4:7320d2a40b92 | 162 | uart.baud(9600); //baud rate set to 9600 |
MI | 1:8834bc22c2e7 | 163 | |
MI | 0:41ed595f83f5 | 164 | //check if starting at main because of LP0 wake-up |
MI | 1:8834bc22c2e7 | 165 | if(LP_IsLP0WakeUp()) { |
MI | 1:8834bc22c2e7 | 166 | |
MI | 1:8834bc22c2e7 | 167 | } |
MI | 0:41ed595f83f5 | 168 | else { |
MI | 0:41ed595f83f5 | 169 | //We did not wake up from sleep and this is first power-on |
MI | 1:8834bc22c2e7 | 170 | //Only configure RTC the first time around |
MI | 1:8834bc22c2e7 | 171 | RTC_Setup(); |
MI | 0:41ed595f83f5 | 172 | } |
tlyp | 3:4af4942a59f2 | 173 | |
tlyp | 4:7320d2a40b92 | 174 | //LEDs on to indicate active mode |
MI | 0:41ed595f83f5 | 175 | gLED = LED_ON; |
MI | 1:8834bc22c2e7 | 176 | rLED = LED_ON; |
MI | 1:8834bc22c2e7 | 177 | bLED = LED_ON; |
tlyp | 2:e4fcc385e824 | 178 | |
tlyp | 2:e4fcc385e824 | 179 | CheckData.mode(PullNone); //Set Interrupt pin to no pull |
tlyp | 2:e4fcc385e824 | 180 | |
MI | 0:41ed595f83f5 | 181 | while(1) { |
MI | 1:8834bc22c2e7 | 182 | //Clear existing wake-up config |
MI | 1:8834bc22c2e7 | 183 | LP_ClearWakeUpConfig(); |
MI | 0:41ed595f83f5 | 184 | |
MI | 1:8834bc22c2e7 | 185 | //Clear any event flags |
MI | 1:8834bc22c2e7 | 186 | LP_ClearWakeUpFlags(); |
tlyp | 2:e4fcc385e824 | 187 | |
tlyp | 2:e4fcc385e824 | 188 | //hold down switch 1 to prevent the microcontroller from going into LP0 |
tlyp | 2:e4fcc385e824 | 189 | //Hold down Switch 1 in order to re-program device |
tlyp | 4:7320d2a40b92 | 190 | while(sw2 == 0); |
tlyp | 2:e4fcc385e824 | 191 | |
tlyp | 2:e4fcc385e824 | 192 | RXEnable = 1; //Enable the Reciever |
tlyp | 2:e4fcc385e824 | 193 | wait_us(250); //Give the Reciever time to wake-up (250us on data Sheet) |
tlyp | 2:e4fcc385e824 | 194 | datacounter = 0; //Reset Data Counter for transaction |
tlyp | 2:e4fcc385e824 | 195 | reading = 0; //REset reading flag |
tlyp | 2:e4fcc385e824 | 196 | CheckData.fall(&CheckUart); //Set falling edge intterupt to check for incoming data |
tlyp | 2:e4fcc385e824 | 197 | wait_ms(5); //Wait for incoming data |
tlyp | 2:e4fcc385e824 | 198 | printf("Checking for data\r\n"); |
tlyp | 2:e4fcc385e824 | 199 | |
tlyp | 2:e4fcc385e824 | 200 | //If CheckData intterupt is triggered, reading flag is set |
tlyp | 2:e4fcc385e824 | 201 | if(reading == 1){ |
tlyp | 2:e4fcc385e824 | 202 | |
tlyp | 2:e4fcc385e824 | 203 | //Variables used for translation of incoming data |
tlyp | 2:e4fcc385e824 | 204 | char dataOut[50]; |
tlyp | 2:e4fcc385e824 | 205 | uint16_t output[2]; |
tlyp | 2:e4fcc385e824 | 206 | |
tlyp | 2:e4fcc385e824 | 207 | wait_ms(50); //Wait for a full transimission of data |
tlyp | 2:e4fcc385e824 | 208 | uart.attach(NULL); //Turn off intterupt on data Read |
tlyp | 2:e4fcc385e824 | 209 | RXEnable = 0; //Turn off Receiver |
tlyp | 2:e4fcc385e824 | 210 | int start = 0; //Variable to find start of packet |
tlyp | 2:e4fcc385e824 | 211 | |
tlyp | 2:e4fcc385e824 | 212 | //Find starting position of full transmission |
tlyp | 2:e4fcc385e824 | 213 | while(dataIn[start] != 'b' && start < datacounter){ |
tlyp | 2:e4fcc385e824 | 214 | start++; |
tlyp | 2:e4fcc385e824 | 215 | } |
tlyp | 2:e4fcc385e824 | 216 | |
tlyp | 2:e4fcc385e824 | 217 | //Make sure this is the starting character for transmission |
tlyp | 2:e4fcc385e824 | 218 | if (dataIn[start] == 'b'){ |
MI | 0:41ed595f83f5 | 219 | |
tlyp | 2:e4fcc385e824 | 220 | //Condense array to just one data transmission |
tlyp | 2:e4fcc385e824 | 221 | if (buildArray(start,dataIn,dataOut) == 0){ |
tlyp | 2:e4fcc385e824 | 222 | //Decrypt message with Symmetric Key and FEC to readible data |
tlyp | 2:e4fcc385e824 | 223 | if (transRx.Decrypt(dataOut,output) == 1){ |
tlyp | 2:e4fcc385e824 | 224 | printf("Error reconstructing\r\n"); |
tlyp | 2:e4fcc385e824 | 225 | } //if |
tlyp | 2:e4fcc385e824 | 226 | |
tlyp | 2:e4fcc385e824 | 227 | //Read Device ID and Type |
tlyp | 2:e4fcc385e824 | 228 | char DeviceType = dataIn[start+1]; |
tlyp | 2:e4fcc385e824 | 229 | char DeviceID = dataIn[start+2]; |
tlyp | 2:e4fcc385e824 | 230 | |
tlyp | 2:e4fcc385e824 | 231 | //Print out the Device Type, ID, and Temperature |
tlyp | 2:e4fcc385e824 | 232 | printf("Device Type: %c\r\n", DeviceType); |
tlyp | 2:e4fcc385e824 | 233 | printf("Device ID: %i\r\n", DeviceID); |
tlyp | 2:e4fcc385e824 | 234 | printf("data = %i\r\n",output[0]); |
tlyp | 2:e4fcc385e824 | 235 | wait(1); |
tlyp | 2:e4fcc385e824 | 236 | |
tlyp | 2:e4fcc385e824 | 237 | //Convert translated data into temperature data |
tlyp | 2:e4fcc385e824 | 238 | float clesius = TempSensor.toCelsius(output[0]); |
tlyp | 2:e4fcc385e824 | 239 | float fare = TempSensor.toFahrenheit(clesius); |
tlyp | 2:e4fcc385e824 | 240 | printf("C = %f\r\n",clesius); |
tlyp | 2:e4fcc385e824 | 241 | printf("F = %f\r\n",fare); |
tlyp | 2:e4fcc385e824 | 242 | } //if |
tlyp | 2:e4fcc385e824 | 243 | //End character cannot be found while condensing array (incomplete transmission) |
tlyp | 2:e4fcc385e824 | 244 | else{ |
tlyp | 2:e4fcc385e824 | 245 | printf("No end character found\r\n"); |
tlyp | 2:e4fcc385e824 | 246 | } //else |
tlyp | 2:e4fcc385e824 | 247 | } //if |
tlyp | 2:e4fcc385e824 | 248 | |
tlyp | 2:e4fcc385e824 | 249 | //Reset dataIn array for next transmission |
tlyp | 2:e4fcc385e824 | 250 | for (int i = 0;i<datacounter;i++){ |
tlyp | 2:e4fcc385e824 | 251 | dataIn[i] = 0; |
tlyp | 2:e4fcc385e824 | 252 | } //for |
tlyp | 2:e4fcc385e824 | 253 | }//if |
tlyp | 2:e4fcc385e824 | 254 | |
tlyp | 2:e4fcc385e824 | 255 | //Turn off intterupt for checking data |
tlyp | 2:e4fcc385e824 | 256 | CheckData.disable_irq(); |
tlyp | 2:e4fcc385e824 | 257 | |
MI | 1:8834bc22c2e7 | 258 | //configure wake-up on RTC compare 0 |
MI | 1:8834bc22c2e7 | 259 | //LP_ConfigRTCWakeUp(enable compare 0, enable compare 1, set prescale, set rollover) |
MI | 1:8834bc22c2e7 | 260 | LP_ConfigRTCWakeUp(1, 0, 0, 0); |
MI | 1:8834bc22c2e7 | 261 | |
tlyp | 2:e4fcc385e824 | 262 | RXEnable = 0; //Turn off Reciever |
tlyp | 2:e4fcc385e824 | 263 | |
tlyp | 2:e4fcc385e824 | 264 | //disable unused PMIC rails to minimize power consumption |
tlyp | 2:e4fcc385e824 | 265 | pegasus.max14690.ldo2SetMode(MAX14690::LDO_DISABLED); |
tlyp | 2:e4fcc385e824 | 266 | pegasus.max14690.ldo3SetMode(MAX14690::LDO_DISABLED); |
tlyp | 2:e4fcc385e824 | 267 | |
tlyp | 2:e4fcc385e824 | 268 | //Reset RTC value |
tlyp | 2:e4fcc385e824 | 269 | RTC_SetCount(0); |
tlyp | 2:e4fcc385e824 | 270 | gLED = LED_OFF; |
tlyp | 2:e4fcc385e824 | 271 | rLED = LED_OFF; |
tlyp | 2:e4fcc385e824 | 272 | bLED = LED_OFF; |
MI | 1:8834bc22c2e7 | 273 | |
tlyp | 3:4af4942a59f2 | 274 | //set RTC to generate an interrupt 5 miliseconds from current value |
tlyp | 2:e4fcc385e824 | 275 | RTC_SetCompare(0,500); |
MI | 1:8834bc22c2e7 | 276 | |
MI | 1:8834bc22c2e7 | 277 | //clear comparison flag in the RTC registers |
MI | 1:8834bc22c2e7 | 278 | RTC_ClearFlags(MXC_F_RTC_FLAGS_COMP0); |
MI | 0:41ed595f83f5 | 279 | |
tlyp | 2:e4fcc385e824 | 280 | //Enter Deep Sleep Mode |
MI | 1:8834bc22c2e7 | 281 | LP_EnterLP0(); |
MI | 1:8834bc22c2e7 | 282 | |
MI | 1:8834bc22c2e7 | 283 | //firmware will reset with no prior knowledge on wake-up |
MI | 0:41ed595f83f5 | 284 | } |
MI | 0:41ed595f83f5 | 285 | } |