We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I need to use the external interrupts of the LPC932. The micro will be in sleeping mode and will be woke up only by these two events. It works fine the first time, but then it does not work any more for external interrupt 0. Why? Could it be my Port configuration on port 1, which is where these two interrupts are entered. These two pins have to be input only. IT0 = 1; //pulses will be edge triggered EX0 = 1; IT1 = 1; //pulses will be edge triggered EX1 = 1; EA = 1; //EBO = 1; //Brown Out interrupt (IEN0.5) PCONA = 0xEF; // turn off all peripherals that can be turned off PCON |= 0x12; // switch to Power Down mode while(1); Thank you!
I checked with an oscilloscope, and the pulses and they are going in to the pin. That proves that your hardware works, now forget about it and fix the software. 1) load blinky to verify your download works, if not fix it. 2) verify that you do not do anything to the watchdog, if you do, remove it. 3) bring your code to an absolute minimum for the problewm you describe and look it over, and if you can not find the software problem show your complete code ISR, main and your complete initialization. Erik
Erik, I usually do steps 1, 2, and 3, but the only problem is a software one. the function Min_Power is called after doing some memory reading and writing. the ISR are not shown here, but they are well developed. void init(void) { P0M1 = 0x00; P0M2 = 0x00; // Quasi-bidirectional P1M1 = 0x00; // Push-pull P1M2 = 0xFF; P2M1 = 0x00; // push pull output P2M2 = 0xFF; P1M1 |= 0x18; // P1^3 and P1^4 as inputs only P1M2 &= 0xE7; ES = 1; // enable UART interrupt EA = 1; } void brkrst_init(void) // This function allows ISP entry through the UART break detect { //AUXR1 |= 0x40; // enable reset on break detect, pg. 102 SCON = 0x50; // select the BRG as UART baud rate source, pg. 60 SSTAT = 0x00; //Timer1 BRGR0 = 0xF0; // 9600 BAUD at @ 7.373MHz internal RC oscillator BRGR1 = 0x02; BRGCON = 0x03; // enable BRG, pg. 59 } void Min_Power(void) { while(1) { IT0 = 1; //pulses will be edge triggered EX0 = 1; IT1 = 1; //pulses will be edge triggered EX1 = 1; EA = 1; PCON |= 0x12; // switch to Power Down mode }
does it work if you do not switch to powersave? Erik
Erik, I have a placed a pull up resistor (5K) on the input pin on interrupt 0. (P1^4). I have removed the Power save intruction of the program, but it still does not work. The pulses are at the port. I checked that with an oscilloscope, but it does not see the interrupts. Can you help me? Thank you while(1) { IT0 = 1; //pulses will be edge triggered EX0 = 1; EA = 1; // PCON |= 0x12; // switch to Power Down mode, valve is closed }
Erik it works fine if I do not switch to Power save. Why is this I thought it would wake up by either interrupt 0 or 1. This is the code I have tried. { IT0 = 1; //pulses will be edge triggered EX0 = 1; IT1 = 1; EX1 = 1; EA = 1; PCON |= 0x12; // switch to Power Down mode, valve is closed while(1); } AND while(1) { IT0 = 1; //pulses will be edge triggered EX0 = 1; IT1 = 1; EX1 = 1; EA = 1; PCON |= 0x12; // switch to Power Down mode, valve is closed }
whatever you do you will stay in the while(1) after wakeup. what good is that going to do? Erik
Erik how can I write this code so that it goes into Power Down Mode and when an interupt INT1, INTO is generated it wakes up executes the ISR and goes back to P.D. mode. This is happening probably every 1/10 of a second. Thank you
see above
Erik I followed the direction from the previous comments. But it does not work if I switch to Power Down Mode. However, it worked on the simulator but not in the application. Why?
it worked on the simulator but not in the application because the simulator simulates. an interupt INT1, INTO is generated it wakes up executes the ISR and goes back to P.D. mode. You need to get the power down out of the ISR. Power down in main and let the ISR wake the uC up. Erik
Erik this is what I have main() proc. { ... ... IT0 = 1; EX0 = 1; EA =1; ... ... } Power_Down() proc. { while(1) { PCON = 0x12; // switch to PDM } } ISR for INT0() { PCON = 0x10; //Normal mode .... ... ... } It works with the emulator, but not with out it. Why.
It works with the emulator, but not with out it. 1) first it was simulator, now it is emulator, what is it? ICE/Keil simul/fried apples? 2) how do you know it does not work in real mode? Erik
Erik I tested on both the simulator and emulator and the interrupt was detected when it occurred. It was executed and goes back to PDM. In real it is not doing it, because the pulses are not being counted. I know this because after a certain amount of pulses something is supposed to happen (about 7 seconds) and it does not happen at all. That is why I know it is not working. Makes sense to you?
Makes sense to you? not at all. You keep feeding me tidbits such as I know this because after a certain amount of pulses something is supposed to happen reduce your code to the VERY MINIMUM you need for this e.g. alternate a LED in the main, then go to sleep, wake up in isrEX0. Try it ICE and real, if it does not work post IT ALL. Erik
Erik I went back to read the user's manual and this is what I found. "In power down mode the power supply voltage may be reduced to the RAM keep-alive voltage VRAM. This retains the RAM contents at the point where PDM was entered. SFR contents are not guaranteed to after VDD has been lowered to VRAM." I think maybe since the contents of some registers are lost after entering PDM, the "pulse counter" is never counting because it is always losing its contents...don't you think? So the micro wakes up, but never accumulates the pulses, therefore not working properly. I may be wrong though.
I think maybe since the contents of some registers are lost after entering PDM, the "pulse counter" is never counting because it is always losing its contents...don't you think? how would I know, you never showed it. I have been communicating under the impression that you showed "the whole truth and nothing but the truth". It is annoying to get information in the 25th post, or whatever the number is, that might have cleared the problem in post 3. Erik