Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 4 months ago.
external interrupt with KL25L
Hi again,
i'm trying to implement some non-blocking functions and generating a uart by software. my problem for now it's how to use the InterruptIn class because it seems not working. I'm planning to use the external interrupt for RX arrive char from external.
int
#include "mbed.h"
DigitalIn button(PTB0);
DigitalOut green(PTB19);
DigitalOut red(PTB18);
DigitalOut blue(PTD1);
InterruptIn int_btn(PTB1);
void flip() {
red = !red;
}
int main() {
int_btn.fall(&flip);
red = 1; //put them in OFF state
blue = 1;
green = 1;
while(1) {
if(!button) blue = 0;
else blue = 1;
green = !green;
wait(0.25);
}
}
If i comment the code which is related with InterruptIn the code is working OK, but if i include it, theRGB LED goes in white state (all outputs logic 1) and this tells me the code seems to be blocked when i'm trying to attach the InterruptIn to the led because when i set outputs, DigitalOut class seems to put the pin into logic 1 state.
Where can I see the sources from classes (InterruptIn, OutputIn/Out,etc)?
The other problems is still not solved, the board is still reseting and in this manner the code i add is erased. For now I'm programming it and change the power supply to the usb port connected directly to the mcu, but it's frustrating because i can't use directly the port assigned to my board. i need to use external RS232 to USB https://mbed.org/questions/4039/Program-loaded-into-FRDM-KL25Z-is-erased/
Cheers, Gabriel
1 Answer
11 years, 4 months ago.
I never saw that message since your editted your old comment, so no mail was sent to inform of the new comment. You are uploading a bin file? How exactly are you doing it? Can you try another PC?
Now for InterruptIn. Here the sources are: https://mbed.org/users/mbed_official/code/mbed-src/file/20b371a9491b/targets/hal/TARGET_Freescale/TARGET_KLXX (well also on other places, but from there you can find other places too).
You should be getting an error message on your serial terminal: The KL25Z can only do interrupts on Port A and Port D, not Port B. Finally, if you are doing this for the fun/experience, go on. If you just want a Software Serial: http://mbed.org/users/Sissors/code/BufferedSoftSerial/
First of all thanks for the information about ext interrupt and code sources. I will try it.
After i download the bin file from the site, i just simply drag and drop into circuit. The green LED status is blinking when the load process is in progress and after it's done the circuit disconnect and reconnect from the PC. Then I press reset button and the app loaded previously works for a couple of time, let's say 10seconds and then the board is reseted (disconnect/reconnect from the pc) again and in the flash directory appears a fail.txt file with "BAD EXTENSION FILE" (without uploading anything)
Yes, I read about the hardware uart, i just want for experience with this board doing by software.
I'm searching for the datasheet of KL25 where i can see the all registers not just the electrical parameters. I searched on the freescale's site but i found just the datasheet where they talk about electrical things. Do you have also the registers from this mcu ?
Thanks, Gabriel
posted by 14 Jul 2014What OS are you using? Maybe an errant virusscanner? What if you upload your program, and then power it using the KL25 USB port? It seems like something is uploading another file to your board which it doesn't understand.
Btw that last link is a software UART already, contrary to regular Serial which is hardware.
For the registers, Freescale calls it a sub-family reference manual, so thats what you need to google on: http://cache.freescale.com/files/32bit/doc/ref_manual/KL25P80M48SF0RM.pdf
posted by 14 Jul 2014Hi Erik. Many thanks for your support! That's the datasheet i was searching it.
I'm using Win7 and I don't have any other PC to test on it. Now i'm doing in that manner, after uploading the bin file, i am powering the circuit using USB port, but this is over hand because i "lose" the Serial communication using the same usb cable and i need to use a Serial to USB converter to communicate with a PC.
Doing in this manner, the chip works OK.
I will scan it and see what's happening. Probably that's the problem. I will update soon.
Thanks again!
EDIT: I have installed a linux distribution and you are right, on linux I don't have any problem with reseting. I have some problems with win7. Thanks
posted by 14 Jul 2014Thats weird. Maybe someone from staff can help (if they don't see this, try mailing to them). I haven't heard of that problem in windows 7 before. Unlikely, but the last thing I can imagine: could there be malware on the PC which is trying to copy itself to the USB drive?
posted by 14 Jul 2014