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!
Do you really want that while(1) at the end?
This is what I think, as long as pulses are not present on either pin INT0 or INT1, the micro will be in Power D. mode. So I guess it will be always looping right? when a pulse is sensed at one the pins then the micro will wake up and go to the ISR of the respective interrupt. When the ISR has been executed it will go back to power d. mode and so forth. What do you think of this...I mean I am still a beginner so you may have a better or the right idea to accomplish this. Can you help me? thanks
With the code you've posted: 1) 8051 enters power down mode 2) External interrupt occurs 3) ISR is executed 4) 8051 remains awake in the while(1) loop. If you want the 8051 to wake up, execute the ISR and power down again you need to write: while(1) { PCON=Whatever it is; } Stefan
Stefan thank you very much for this info. But don't I need to set the interrupts' bit enable and specify it's edge triggered? (I mean all the time), which will be done by including them in this loop? Thanks
But don't I need to set the interrupts' bit enable and specify it's edge triggered? (I mean all the time), which will be done by including them in this loop? both bits stay as they are till you write differently to the SFR. Erik
Can you post the complete but minimum code that you are having trouble with? Stefan
Stefan these are the changes I have done, after yours and Erik's comments. I have commented out INT0 and INT1 enable bits, as well as their edge detection bit (ITO and IT1). I put them in the main program procedure. I think one of the problems I am having is configuring the port's pin as inputs only. for instance Port1 is P1^3 for INT0 and P1^4 for INT1. I have read the user's manual and P1^3 can only be input or open drain. and P1^4 has to be an input also right? so I did this P1M1 |= 0x18; and P1M2 &= 0xE7; which I think will made these pins input only right? so, I am supposed to be seeing a high on P1^3 (INT0) and just don't get that... Do I need EA = 1 in this loop, or do I need something that it is not there?...I am going nuts with this...i will appreciate if you help me. I read and read, look at application notes, try different things, but it just does not work. I am using the EPM900 emulator board by the way. 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 }
I have read the user's manual and P1^3 can only be input or open drain. ... I am supposed to be seeing a high on P1^3 (INT0) and just don't get that... How, just how, can an input or an open drain be expected to go high unless an external signal drive them there? Erik
Erik are you referring to a pull up resistor or the signal that will triggered the interrupt? Also, this pin (INT0) has to be an input and according to the user's manual the open drain configuration recommends an external pull up resistor tied to Vdd, but not for the input configuration. Thanks
Ok, now read this(if you need do it multiple times) To generate an interrupt you must have something driving the interrupt pin on the 932. Whether that pin is high or low does NOT depend on anything in the 932, it depends on the output of the device driving the pin. Erik
Erik, can you please be more specific, because I do know which way to go. I need the pin to receive pulses every 1/10 of a second. this may be endless pulses. The way I have it now is with a resistor 10K connected to the pin from one end and to Vdd from the other end. I checked the pin and it has 3.3 volts on it. But it still does not accept the pulses. I checked with an oscilloscope, and the pulses and they are going in to the pin. What is left to do? 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 }