This page is for you! If you’d like more information about something I’ve posted about, or if there is a topic you think I should post about, please leave a comment and I’ll get right to it (as fast as my schedule permits it)!
I have started to list things in my bucket list (still ongoing).
For feature requests or bug reports on the McuOnEclipse project end Processor Expert components, you should use the GitHub issue tracking system:
- McuOnEclipse Processor Expert components: https://github.com/ErichStyger/McuOnEclipse_PEx/issues
- McuOneEclipse example projects: https://github.com/ErichStyger/mcuoneclipse/issues
Hi Eric,
I hope you’re very well, thanks a lot for your help the last time my LCD works (the character “Hola” appeared), but now I have 2 questions:
1. Is possible to made an ENABLE2 in your LCDTHA library? If would be possible:
What part of the code should I modify? (My LCD has 4 lines and 2 enables, I thought EN1 was an “ENABLE2” but it didn’t work 😦 )
2. Can I made an interruption from an input external signal?? (I did this question because I need to syncronize a output PWM signal with an external signal ( for example:half wave, sine,etc)).
Let me tell you I’ve learned a lot!! 🙂
Thanks and Regards!!
LikeLike
Hi Luis,
1) Yes, it is for sure possible to add that additional pin to the code, but it will not be a single place to modify. Probably one hour or two of work with reading the data sheet. The issue is just that I probably will not find enough time, at least for now.
2) Yes, you can create an interrupt from an external signal. I use the ExtInt (or InterruptVector) component for this, see https://mcuoneclipse.com/2013/11/17/processor-expert-component-not-showing-up/
LikeLike
Hi Eric!!!
I hope you’re very well
Might you add other pin in your code (LCDTHA library) the next week please?
It’s important for us to made an ENABLE2, this is my LCD:
Click to access NHD-0440WH-ATFH-JT.pdf
Please we need it for our project.
Thanks a lot and Regards!! 😀
LikeLike
Hi Luis,
that will be very hard for me to do: I do not have this display available, so I cannot test it. And worse, I have an extremely busy week ahead of me. The earliest I could look into this next week end, but for sure not earlier :-(. Given my current workload, I even could not promise anything.
LikeLike
Hi Eric,
Take it easy!! thanks a lot for all your help, maybe you can tell us where can we start to modify your LCDHTA library.
Thanks again!!! and we’ll wait your answer!!
Regards
LikeLike
Hi Luis,
have a look in https://github.com/ErichStyger/mcuoneclipse/blob/master/Drivers/sw/LCDHTA.drv where it selects the current line and writes to the display.
LikeLike
Hi Eric,
Where I’m in Processor Expert, where can I modify this driver??
Regards
LikeLike
Hi Luis,
You can use a normal text editor. Or you would need to use the CDE (Component development Environment), see https://mcuoneclipse.com/2013/03/31/tutorial-creating-a-processor-expert-component-for-an-accelerometer/
LikeLike
Hi Eric,
I have some problems with my Processor Expert, when I try to generate code for my PWM, it says:
I’ve unistalled and installed 10.5 again, but I ‘ve had the same result.
How can I fix it?? Regards
Generator:FAILURE:Unexpected status of script Drivers/Common/PWMSettings.inc
I have unistalleds
LikeLike
Hi Luis,
that really sounds like a bug in Processor Expert :-(. I suggest that you submit this to Freescale.
The problem might be related to some of the settings. Does it happen as well if you add a new PWM to your project? That way you might find a way to isolate which setting is causing this.
LikeLike
Hi Erich,
In kl25 it says that it’s architecture is two-stag pipeline, do we have to do anything to activate this pipelines or they are activated by hardware it self ?
And, so for Uart DMA, how to activate it ?
thanks for your helps 🙂
LikeLike
The pipelines are enabled by default in the hardware, to my knowledge there is nothing you have to do or can do for this.
As for DMA: I used it only for Bit I/O. Have a look here:
LikeLike
Hi Erich! I’m working with a matrix keypad 3×5, do you have examples with keyboards or keypads?, I’m planning to use some interruptions and some BitIOs to determinate the exact key pressed. Also I have the same problem with an LCD with 2 enables, as Luis’ case, do you recommend me to create a new component with the Enable 2 ?
LikeLike
Hi Daniela,
no, I don’t have such a keyboard example readily available, but it should not be too hard to create one. I have a 4×4 matrix keyboard I could use. However, I would not recommend to use interrupts for this (well, you could), as it would neeed too many interrupt lines. I rather would scan the keys frequent enough as timing is not that important.
As for the LCD with two enable lines: You do not need to create a new component: you cold copy-paste the code of the existing component (generated code) and then add the second enable line?
Erich
LikeLike
It is a great website. Thanks a lot for all the efforts. I gained a lot as a beginner barely getting my feet wet on USB. I would appreciate it if you make a tutorial on how to create a device to be accessed through Winusb. I tried to modify the CDC device to work with Winusb but having lots of problems. Your guidance is highly appreciate it.
Mustafa
LikeLike
What exactly do you want to achieve? Implementing a custom device class and using it with WinUSB? What prevents you to use the USB CDC class instead?
LikeLike
I am doing basic exercise on USB device communications using freescale frdm board. I used the CDC class successfully and managed to talk to it as a comport. My next step is to create a custom device class to use with Winusb driver. In this effort I modified the CDC class parameters and loaded Winusb driver successfully but could not talk to the endpoint. Once again I appreciate your help.
LikeLike
Hi Mustafa,
Ok, I understand now. But I’m affraid, that I have not done this (yet?), and in my view this requires deep understanding of the big USB stack and standard. Doable, but not something to do in just a few hours. At least for my projects, I needed to communicate between the host and the device, and for this the USB CDC was more than sufficient.
LikeLike
Thanks Erich
My understanding of Winusb custom device should be similar to CDC device. The difference I believe is in polling the controller to determine which EP has fired the interrupt and calling the proper callback function accordingly. Any way I’ll keep looking around for any clues though I am doing this as a side project. I’ll let you know if I find any solution.
Mustafa
LikeLike
Hi Eric
I was seeing you LCDTHA.drv, but I don’t know where to put the ENABLE 2 in your code. I need to adapt it for my LCD with 2 enables…. 😦
Click to access NHD-0440WH-ATFH-JT.pdf
LikeLike
Hi Luis,
that display is really a weird one :-(. It seems that they have put together two display controllers sharing all data lines except the EN one. I have now added that support to the LCDHTA driver (commited on GitHub sources a few minutes ago). But please understand that because I do not have a display to test this, I’m not sure if it really works. If you want to try it out:
a) configure the component to use 2 (!!!) lines
b) configure all signals, plus the E2 line
You need to treat the display like two 2-line displays. For this you need to use the new LCD1_UseDisplay() method. Example:
LCD1_UseDisplay(1);
LCD1_Write(‘A’); /* writes to display 1 (upper lines) */
LCD1_UseDisplay(2);
LCD1_Write(‘B’); /* writes to display 2 (lower lines) */
I really hope that this works.
LikeLike
Hi Erich.
Do you have a project or tutorial about I2S ( design by CodeWarrior and ProcessorExpert)? I am designing I2S with MK20DX128VLH5( kit FRDM K20D50M), but i didnot see any project to refer.
LikeLike
No, I have not used I2S and I do not h ave an example or tutorial for it. Sorry!
LikeLike
Hi Eric,
I hope you’re very well!!!
I have a question about my PWM signal!! I need a PWM with frecuency=60 Hz (Period=16.667 ms), but when I see the oscilloscope my PWM has a frecuency=71.14Hz. I don’t know why, because in the settinhs of the PWM library I put period=16.667 ms. :-S
Do you know where is the problem??
Regards!!
LikeLike
Hi Luis,
yes, doing fine (fighting with nRF24+ issues ;-).
About this PWM thing: that would be new for me. Are you measuring correctly the time between two rising edges? Otherwise, could it be that your clock settings are not correct? That you have specified say a 8 MHz crystal, but using something different?
LikeLike
Hi Eric,
I did well the measure and it shows me 71.14 Hz 😦
Clock Settings:
Internal Oscilator
Slow Internal Reference clock: 32.768 KHz (Frecuency from 31.25 to 39.062 KHz).
Fast internal reference clock: 4 MHz (Frecuency range from 3 to 5 MHz)
Regards!!!
LikeLike
Hi Luis,
can you toggle a pin from a timer interrupt to check if it toggles at the right speed? It looks like your internal oscillator is off? Can you use an external crystal instead?
LikeLike
Hi Eric,
Toogle a pin from a timer interrupt?? How can I do that?? I put the external crystal but I had the same result…..
LikeLike
Yes, add a periodic timer interrupt and then in the interrupt service routine toggle a LED/output pin.
Is this for a FRDM board?
LikeLike
I have a TWR-K20
LikeLike
TWR-K20D50M or TWR-K20D72M?
LikeLike
TWR-K20D72M
LikeLike
Hi Luis,
I added a 60 Hz PWM (Buzzer) to my project on
https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/TWR-K20D72M/TWR-K20D72M_USB_CDC
I measure a period of 16.719 ms (59.81 Hz).
LikeLike
Hi Erich,
I am using Freescale K60 in my device and I am running a device specific application in it.
It is running for some time and then K60 is getting reset. I found that the reset is caused by core lockup event. I want to know the set of lines of my code, where this core lockup event occurred.
Is that possible?
Please let me know, If you are aware of what can be done to know the reason for such case.
Thanks,
Jagadeesh Cherukuri.
LikeLike
Hi Jagadeesh,
do you get first an interrupt before reset? Maybe a hard fault interrupt? Then you could read the program counter or the stack content and you would know where the problem happened. As for reasons for reset: there could be many things, but really it would depend on the reset type. A common source is a power supply problem. Monitor your power supply voltage if it drops somehow? It even might be a silicon bug?
LikeLike
Hi Erich,
Thanks for a quick response. I did not get any interrupt before reset. My reset type is core lockup event reset. I am giving power to the device using mini USB power port soldered to my module. I am observing this issue, only when I am USB of K60 is active. Otherwise, the same application is running fine.
Regards,
Jagadeesh.
LikeLike
Hmm, that’s strange. Maybe this is still a power supply issue? I have never encountered such a lockup event. Could you try if you power the CPU not only with USB, but with a regular power supply? Just to get a possible power supply problem out of the way. Otherwise I think a Freescale FAE would need to look into this issue.
LikeLike
Hi Erich,
I tried that. But, no luck. Still I can see the issue.
Regards,
Jagadeesh.
LikeLike
Hi Erich,
I’m trying to use SMAC with the 13201 RF transceiver and the QE128 HCS08 microcontroller with your component and I’m very lost 😦
Could you take a time to make a more detailed post about SMAC and how to use it?
I would be very grateful 🙂
LikeLike
How grateful? 😉
I have not used the S08 QE128 for a while, and would take me some time to grab the hardware and to set it up. Doable, but would take me some time. Let me see what I can do for you. It is Christmas time 🙂
LikeLike
Hi Carlos,
Merry Christmas!
I have created a project for the DEMO QE128 board on GitHub: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/DEMOQE/DEMOQE_S128_RNet
If I find time in the next days, I write up a short tutorial about it. But it should help you to get you started.
The application is using the RNet stack (see https://mcuoneclipse.com/2013/11/17/rnet-a-simple-open-source-radio-network-stack/)
I hope this helps.
LikeLike
Hi Carlos,
have a look at this post:
I hope this helps, and Merry Christmas 🙂
LikeLike
Hi Eric,
Merry Christmas!! I have a question:
Is possible to compare an ADC output with a voltage value (offset), using Processor Expert??
Thanks a lot for all your help!!!
LikeLike
Hi Luis,
Merry Christmas!
What if you read in the Voltage with a separate A/D channel?
LikeLike
Hi Eric,
In my TWR-K20D72M I need to use 2 ADC’s to compare my signal 1 (ADC0) and signal 2 (ADC1) with an offset value!!! For example:
if (S1>S2) {
S1/S2
else
S2/S1
}
and then I have to compare (S1/S2 or S2/S1) with an offset (voltage)….
LikeLike
Hi Eric,
I have other question;
Is possible to save values of ADC in an array??
For example:
uint16_t S1;
uint16_t Save[2];
int i;
while(interrupt=TRUE) {
i=0;
Save[i]=AD1_GetValue16(&S1);
i++;
}
Thanks and Regards!!
LikeLike
Hi Luis,
you can use such an array only if you sample multiple channels. You cannot use it for a single channel.
And: the return value of AD1_GetValue() is an error code.
LikeLike
So…. How Can I save the values if I want to use for S1 ( in ADC0) and S2 (in ADC1)????
If I use an ADC ( with 2 channels for S1 and S2), should I do 2 arrays???
Thanks!!!
LikeLike
If you are using one ADC component, then you can save all channels into one array. If you are using two ADC components, then each ADC component needs its own array.
LikeLike
Hi Eric,
I was testing your update LCDTHA library (with Enable 2),I wrote the code:
for (;;) {
LCD1_WriteLineStr(1,”Hola”);
}
but it shows me:
””””””””””””””””””””””””””””””””””””””””””””””’Ooog””””””””””””””””’
,,,,,,,,,,,,,,,,,,,,,,,,,,Ooog,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Ooog,,,,,,,,,,,,,
Also, when I use LCD1_UseDisplay(1), my program stoped (debug).
How can I fix it??
Regards!!
LikeLike
I think without the hardware it will be really hard for me to find out what is wrong 😦
LikeLike
Hi Eric,
Can I buy a LCD (with 2 enables) and then send to you??
What do you think??
🙂
LikeLike
Or do you have a shop address where such a display can be ordered? The other thing I was thinking about: I could combine two normal 2-line displays and then test this out. Would not have the same timing as your display, but better than nothing. Of course having the same hardware/display would be the best.
LikeLike
Hi Eric,
I hope you’re very well, this is the shop address in Mouser.com:
http://cr.mouser.com/ProductDetail/Newhaven-Display/NHD-0440WH-ATFH-JT/?qs=%2fha2pyFadugKZtLbc3gXzv1uOgJ4J5qd1vPDbvh36LbqdXxrtAaB68gS%252b0FfUyjC
This project is important for us because we are in our graduation project 🙂
Regards and Thank you very much!!!
LikeLike
Sorry my email is: lsanz84@gmail.com
and if you want, we can test the other possibility: combine 2 lines of display!!
Thanks!!
LikeLike
I will try on my end as well to combine two normal 2 line displays to test the driver.
LikeLike
Hi Luis,
thanks for the link to the display. But Mouser will probably not be able to deliver it in the next days because of the New Year break. I give it a try to combine two displays. I have two TJK Displays (see https://mcuoneclipse.com/2012/12/22/hd44780-2×16-character-display-for-kinetis-and-freedom-board/) which I will use. I’ll keep you updated.
Erich
LikeLike
Thanks a lot Eric!!! 😀
LikeLike
Erich,
I noticed you used lipo batteries to power your Zumo. I used to dabble with electric helicopters and still have my lipo charger and even some cells still.
I remember that over discharging lipos was bad. However, it was easy to notice when a helicopter was starting to lose power and stop early. I’m not so sure the same is true with small robotics applications where there is usually not such a demand for power. But maybe it’s not such an issue if there is not high current draw.
Anyway, I’d like to use lipo batteries for my applications but do you have any particular cautions or advice, particularly with regard to powering the microcontroller side of things?
Curiously,
Tom.
LikeLike
I only used LiPo in a very controlled fashion (exactly to avoid the discharging). I used most simple NiMh cells which are heavier, but more robust. And weight is an advantage for Sumo :-). If you are going to use LiPo, then I suggest that you monitor the voltage of the cells: if you are only discharging, then you need to add a circuit/check to prevent the voltage to drop below the minimal allowed voltage of the cell. Otherwise you will destroy the cell. To be perfect, you would need to monitor the cell temperature too.
LikeLike
I searched for a lipo cut-off circuit I could use but I’m thinking such a thing is not practical? When powering motors, or other higher current drawing devices, would there not be momentary voltage drops/fluctuations that would give false positives?
I was also very surprised that cut-off circuits are not readily available for lipos, or at least they don’t seem to be. I guess most hobbyists use NiMh cells.
Another sub project to add to my growing list. 🙂
LikeLike
Yes, when I looked that the same thing, I have not found anything really useful. Especially I was surprised why this is not an option or even built into the cells.
LikeLike
I found some simple lipo alarm/buzzer gadgets I can use. The lipos I own have separate connectors for balanced charging, and the alarm device just plugs into those. Very cool.
Sorry for the rambling.
LikeLike
Yes, I have found those alarm or blink gadgets too. But they only beep or warn, but do not prevent going down the minimal voltage. So they are ok if you are near the battery (so you can switch it off), but they do not help you if you are away? I mean they are usueful for RC models/toys where you are supposed to switch off the device after you finished playing with it, but they do not actually cut off the power?
And yes: Lipos with multiple cells typically have balancing connectors so you can measure the voltage of each cell.
LikeLike
hi erich
thanks a lot for all those tutorials its very very usefull !!
is it possible to have more details on how to do multiple channels differential adc with the kl25z!!!!!!
thanks a lot for the help
LikeLike
Hi Ilian,
I would love to, but my time is limited, and I’m doing this in my free/spare time (as other folks in the community). Maybe you could ask your question in the Freescale Forum?
LikeLike
hi erich,
I was searching for FRDM-KL25Z eagle library and found your upload on github.com.
I was not able to download it. If can you please mail me or upload the library on your blog
LikeLike
Hi Aayush,
maybe you have a problem with your browser or internet connection?
In that case I recommend that you download the repository as zip file:
https://github.com/ErichStyger/mcuoneclipse/archive/master.zip
LikeLike
thanks a lot for the help and thanks a lot for all those tutorials its very very useful !! Great work 🙂
LikeLike
Hi Erich, can you add a funture to the KEY conponent , add “Hold” state to the driver, blow i paste my code(maybe some bugs in it, buy it works ) for your reference . Thanks.
static void Scan(void)
{
KEY_UP_KeyStorage keys;
static uint8_t cnt = 0; //for delay count
static uint8_t hold_trig = 0; //for state trig
EnterCritical();
switch(DBC_KeyState) {
case DBC_KEY_IDLE: /* Idle, and now getting a key */
DBC_ScanValue = KEY_UP_GetKeys(); /* a one bit indicates key pressed */
if (DBC_ScanValue==0) { /* no keys pressed */
ExitCritical();
return;
}
DBC_LongKeyCount = 0;
DBC_KeyState = DBC_KEY_PRESSED; /* advance to next state */
KEY_UP_OnKeyPressed(DBC_ScanValue);
TRG1_AddTrigger(TRG1_KEY_UP_PRESS, DBC_DEBOUNCE_TIME, Scan);
break;
case DBC_KEY_PRESSED:
keys = KEY_UP_GetKeys(); /* a one bit indicates key pressed */
if (keys == DBC_ScanValue) { /* still pressing the same keys */
DBC_LongKeyCount++;
if (DBC_LongKeyCount >= DBC_LONG_KEY_ITERATIONS) {
/* yes, long key press detected */
DBC_LongKeyCount = DBC_LONG_KEY_ITERATIONS; /* avoid overflow */
DBC_KeyState = DBC_KEY_WAIT_RELEASE_LONG; /* advance to next state */
TRG1_AddTrigger(TRG1_KEY_UP_PRESS, 1, Scan);
} else {
TRG1_AddTrigger(TRG1_KEY_UP_PRESS, 1, Scan); /* continue waiting */
}
} else { /* we got set of key(s): so it was only for a short time */
DBC_KeyState = DBC_KEY_WAIT_RELEASE; /* advance to next state */
TRG1_AddTrigger(TRG1_KEY_UP_PRESS, 1, Scan);
}
break;
case DBC_KEY_WAIT_RELEASE:
case DBC_KEY_WAIT_RELEASE_LONG:
/* wait until keys are released */
keys = KEY_UP_GetKeys(); /* a one bit indicates key pressed */
if (keys==0) { /* a zero bit means: key(s) released */
if (DBC_KeyState == DBC_KEY_WAIT_RELEASE_LONG) {
//###########################################
if(hold_trig){} //hold key event happened
else{
//if key press event enabled, we call OnKeyPress() here,
//otherwise, we call OnKeyRelease(),
//if both enabled, we can chose which one should be call here
KEY_UP_OnKeyReleased(DBC_ScanValue);
}
hold_trig = 0;
//###########################################
KEY_UP_OnKeyReleasedLong(DBC_ScanValue);//if we enable hold feature, should be no this line
} else {
KEY_UP_OnKeyReleased(DBC_ScanValue);
}
/* All keys released, go back to idle state. */
DBC_KeyState = DBC_KEY_IDLE; /* go back to idle */
//######################################
cnt = 0; //clear the delay count
//######################################
} else { /* continue waiting */
TRG1_AddTrigger(TRG1_KEY_UP_PRESS, 1, Scan);
//we add key_hold event here##############
//only in long wait state we call hold function
if(DBC_KeyState == DBC_KEY_WAIT_RELEASE_LONG){
if(cnt<10) { //delay count for calls per second
cnt++;
}
else{
cnt = 0;
hold_trig = 1;
KEY_UP_OnKeyHold();
}
}
//########################################
}
break;
}
ExitCritical();
}
LikeLike
Hi Kevin,
what you want is to have a ‘hold’ events created while the key is pressed? Say a hold event every 50 ms or so until the key state changes? Is this what you want?
LikeLike
yes, we can chose to enable the hold event or long release event , when we enable hold event, the HoldEvent be called every 50ms or any other time periodly until we release the button
LikeLike
Hi Kevin,
I have implemented an event OnKeyHold() on GitHub:
https://github.com/ErichStyger/mcuoneclipse/commit/96aed2086954a3dd5c17844f915d2692ddb07f15
It gets called while it counts for the long key event. This should help you?
LikeLike
How about ModBus Component…
LikeLike
Hi Moise,
yes, good idea! It is only that I do not use ModBus in my designs. Maybe you can create such a component?
LikeLike
hi Erich and Hong,
I am also porting FreeRTOS on S12G128 on a bareboard. I am a beginner. I just wanted to ask what if I dont want to use Processor Expert. What all files I have to import in my project and what all things I have to modify accordingly to make FreeRTOS run?
It will be a great help.
LikeLike
Hello,
Because Processor Expert makes things much easier, I would suggest that you give it a try. You still can copy/use the files without Processor Expert.
As for the files: have a look at the list of files here: https://github.com/ErichStyger/mcuoneclipse/tree/master/Drivers/freeRTOS
LikeLike
hello..
how about trkmpc560xb board with arduino..
i want to send signal from arduino to that board.. arduino it running an image processing to detect the object then it send the signal to trkmpc560xb board to run the servo motor..
TQ
LikeLike
Unfortunately, I do not have that board 😦
LikeLike
Hi Erich,
In kl25 manual it says that we can use all digital pins as interrupt, but in CW (with Processor Expert) we can’t use all those pins?
Can you tell me how to enable all digital pins as interrupt ?
Thanks for you work.
LikeLike
I’m not sure if all pins can be really used for interrupts?
LikeLike
Hi Erich,
I am just wondering do you know how to transfer signal from raspberry pi to KL25z through PTE01 and PTE00 (I2C)?? Can you teach me how to link those two devices?
Thank you.
LikeLike
Hi Xfrost,
no, I have not done that (yet?). If you find out, could you post it?
LikeLike
Hi Erich.
I try to use the TouchScreen Component, but i don’t know how connect it.
Where I need to conect the ADC pin ??
Have you any example of use ?.
Thank’s a lot.
LikeLike
Hi Sergi,
I have several projects here:
https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples
LikeLike
one of the things that drives me nutts in a 32 bit system is when you are having to interact with say a port that is 32 bits regihster and find bit 12 or 16 … in the 32 bit binary
so i thought that there must be a eclipse plugin that at miniumim takes the 32 but binary and places a space char between each set of 8 bits… well i could not find any thing
i do know that if it was a bit in my code i could seperate it out a bit but ports are a realy pain
got any ideas
LikeLike
Hi Dan,
I would think that the normal memory view (https://mcuoneclipse.com/2012/02/04/memory-is-everything/) would do this?
LikeLike
its a bit better yes… but i spose that eclipse started off more or a pc app ide not so much a embeded ide
LikeLike
Eclipse is really more of a ‘framework’ for pretty much everything: web development, java development, C/C++, document writing. I have even seen monitoring applications which are using Eclipse as framwork! And yes, that versatility can be confusing, as it is probably too much: too much flexibility, too much possibilities. I compare it like the switch from the ‘old DOS command line world’ to the ‘GUI Windows/Linux world’: that was confusing at the beginning too (too much functionality), but at the end I think most of us do not want to get back to the old DOS command line world 😉
LikeLike
Hi Erich,
If you get some time could you please do an idiots guide to creating PE components?
I think there is one for the accelerometer but i not find it detailed enough.
How do you create Events, Functions, enable / disable functionality etc it would be great if you could find the time to do a starting from scratch guide
LikeLike
Hi Andu,
I was hoping that Accerometer one would be a good start. It already covers creating functions/etc, and I would consider it as ‘from scratch’?
LikeLike
Hi Erich,
I have a project for a development board for freescale microcontrollers which uses USBDM, for this board i have created a full list of Arduino-like libraries to fit into the microcontroller.
The problem is that the only way i have to create a new project using the folder structure needed for my project (header files, custom main.c file, etc…) is importing an existing project.
I´m trying to do a plug-in for the codewarrior eclipse version that allows me to create a “template” with all the necessary files, but i jus cant to it…
Something like a menu toolbar where you can list as follow:
DevBoard
–> New DevBoard Project
–> Examples
–> DigitalWrite
–> DigitalRead
Can you please help me on this?
LikeLike
You need to write some piece of Java code, like what Liviu has done with his plugin (he provides projects templates). See
gnuarmeclipse.livius.net/blog/
and
LikeLike
This is what I needed: gnuarmeclipse.livius.net/blog/ now I have templates and life is good, I also made the decision to go with a j-link debug solution while they workout the issues with OpenOCD/OpenSDA.
LikeLike
Hi Erich.
I can suggest you to do an article for the use of FAT without using FreeRTOS, as you did in “freescale community thread/303618” forum.
After much searching, I found that example to fix my problem, because all the examples you use, always using the FreeRTOS.
Greetings and thanks for your website..
LikeLike
Erich,
I used the quicky method you described to download the free version
of eclipse, the arm toolchain. processor expert, etc. I am not using
codewarrior. I bought a couple of the freedom boards. I was able to compile
a blinky program for the K25z, and now I want to get it onto the freedom board.
I went to pemicro and registered the board and put all the latest pemicro opensda f/w
on it. But here is where I get stuck.. I copied an srecord file to the board,
but I dont think it runs after a reboot. The srecord file seems to disappear after reboot.
also, I dont seems to be able to run gdb using opensda/pemicro gdb server.
Can you maybe point me to the right place to get through these issues
use eclipse without codewarrior, with opensda debugging?
Thanks in advance,
SteveH
LikeLike
Hi Steve,
that the file disapperas is normal. But to debug the OpenSDAv1 Board, you need to load a different firmware than the one shipped with the factor boards. Have you udpdated the firmware so you can do debug *and* MSD bootloading? See https://mcuoneclipse.com/2013/12/14/new-pe-opensda-firmware-v114/
I hope this helps,
Erich
LikeLike
Erich,
I did that, and when you click on it, it goes to the pemicro site and shows you the correct firmware versions.
Is the bliky led the same grenn led that blinks that is close to the opensda proceocessor, or is it somehere else?
when I copy the srecord file, the thing still seems to run the code to change the colors on the 3 color led..
Also, can you point me to somehwere in your blog that
talks about using opensda and gdb, without buyong a segger or pemicro jtag probe? I only want to use the freedom boards I have for now..
LikeLike
Hi Steve,
yes, I mean that green blinky LED close to the OpenSDA K20.
If your S19 file does not change the code, then obviously nothing has been programmed.
You do not need a Segger or P&E probe: the Segger and P&E GDB happy talks to the OpenSDA Segger and OpenSDA P&E firmware on the Freedom board.
See https://mcuoneclipse.com/2013/07/22/diy-free-toolchain-for-kinetis-part-3-debugger-gdb-server-with-pe-and-segger/
LikeLike
Erich,
Thanks for your reply. I will give it all another try later today.
BTW, Do you think that KDS is any simpler to use?
SteveH
LikeLike
Hi Steve,
>> BTW, Do you think that KDS is any simpler to use?
It all depends what ‘simpler’ is for you? KDS is still Eclipse, so for anyone who does not like Eclipse at all, it will not be different.
What makes it simpler is the it is using the GNU ARM Eclipse plugins (which are state of the art for me), plus compared to stock Eclipse+gdb the creation of launch/run configuration is much better.
Erich
LikeLike
Hi Erich,
I managed to get my freedom board running with
The pemicro gdb server using opensda.
Thanks for your great site here..
SteveH
LikeLike
Erich,
Well almost….
When I try to denug the blinky program, It seems
th code gets stuck in the default systick handler..
I think my setup is not honoring overriding the “weak”
attribute for the default Systick handler, and is linking in the default one.
instead on the one in the main.cpp file
Can you tell me the way around this? Do I need newer plugins,
or a different linker command?
Thanks
SteveH
LikeLike
Hi Steve,
can you verify that your theory is true with the map file generated by the linker? Or maybe you are linking a wrong library?
LikeLike
Erich,
I checked the map file, it seemed to disprove what I was thinking. I also checked my plugins, I have new ones. So I went back and eventually found a self inflicted bug …. D’oh!??
So now blinky is oak…
Thanks
SteveH
LikeLike
Erich,
I have an unusual USB hardware setup and wonder if you have any suggestions to a problem I’m seeing. My USB device has hardware that switches it between two hosts. When it is enumerated with Host A and I want to switch to Host B, it thinks Host B is still Host A. My guess is that there was not time for it to logically detach from A by the time it is physically connected to B. Is there a command to force an enumerated device to detach itself from the host?
Thanks,
Greg
LikeLike
Hi Greg,
this is indeed unusual, not seen something like this. Can you add a delay to see if this makes a difference? Otherwise I do no remember that I have seen a disconnect command.
LikeLike
Hi Erich,
we are using a KL25 MCU and would like to implement a OTA update mechanism to update the device firmware on the field. I read that Freescale has this very nice P-Swap Flash mechanism (http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4533.pdf) that would fit very nice into our concept but unfortunatelly it is avaibale only in the higher grade MCU not KLx series. Do you have any recommedation how to approach this problem using KLx MCU’s?
Thanks in advance.
Best regards,
Panayot
LikeLike
Hi Panayot,
Well, you only can simulate this to some extend that you program one part of the flash, and then copy everything in one step. But this requires that you need to double your flash size. But I think the best if if you just do it the traditional way in KL.
Erich
LikeLike
Hi Erich,
thanks for the reply. What do yo mean by traditional way?
Best regards,
Panayot
LikeLike
Hi Panayot,
that you do not use the swap features: that you program the new application ‘in place’.
Erich
LikeLike
Hi Erich
It would be good to have an example of the use of FreeRTOS in an interrupt-driven Processor Expert application, including topics like:
– the relationship between low-level hardware interrupts and PE events (in Events.c).
– when to use the FreeRTOS “FromISR()” routines, and why (what they actually do differently)?
– Interrupt priorities and FreeRTOS priorities, the relationship between these, and how to use these.
– the FreeRTOS Critical Sections and the PE Critical Sections, and when to use one and when to use the other.
– when to use the PE WAIT component and when to use FreeRTOS TaskDelay() function.
Time for another great Erich blog post, or maybe you have already got an example?
Regards – Charles
LikeLike
Hi Charles,
indeed, many good questions. I have answers for all these, but guess I need to find some time for the write-up. Some parts of the answers are inside my projects on GitHub, but I admit scattered in many projects.
Erich
LikeLike
Hi Charles,
sorry, that it takes so long to get answers to your wish list, as my backlog is growing and growing. But at least this week-end I think I can provide an answer to your first question:
More to come (slowly), ….
Erich
LikeLike
Hi Erich,
we are trying to use KDS 1.0.1 Beta to compile a project c/c++ mixed for K21 imported from CW 10.5.
We found that the startup.c routine does not call the global c++ constructor initializers. The __call_static_initializers() is commented. Do you know which flags of compiler/linker can be used to enable again this feature?
Thank you.
Kind Regards
Andrea
LikeLike
Hi Erich
While trying to debug some instability in my system I created a FreeRTOS task that toggles a GPIO pin every second:
for (;;) {
ScopeTrigger_Toggle();
FRTOS1_vTaskDelay(1000/portTICK_RATE_MS);
}
This runs as expected until I start my main code running. This code loops sending commands to a Bluetooth chip via SPI, waiting for an interrupt back, and printing commands and status using the console. At this point the GPIO pin sometimes toggles in less than 1000ms. The effect varies depending on my main loop, but I see a stable pattern of a few periods of 1000ms followed by one shorter period (100ms – 650ms). Furthermore, the GPIO loop is in sync with my main loop (it should free-run asynchronously). When I disable Tickless Idle Mode it works properly, and the tasks don’t get in sync. So: how could activity elsewhere cause the GPIO task delay to be truncated and so synchronise with the main task? There must be interrupts happening from the SPI and UART blocks as well as the interrupt from the Bluetooth chip.
I will dig further myself, but wonder if you have any comments on where to look. (PS – is this the right place to ask this question?)
LikeLike
Are you sayinig that only in tickless idle mode you see an issue? Still in tickless idle mode it should be very close to 1000 ms.
100 or 650 ms look wrong. Then it looks like the tick calculation might have an issue I have not seen (yet).
The SPI/UART interrupt should leave the tickless idle mode, and the tickless idle code in the RTOS should then adjust the new tickless idle period accordingly.
Would be good to have some details of your setup:
– tickless idle mode? Only with the SysTick (no low power timer)?
– what is the priority of your ScopeTrigger_Toggle Task?
– what is the priority of your ‘main’ task?
A very small example project would help to dig into this (preferably for a FRDM-KL25Z board (or K20).
And yes, that’s not a bad place to ask 🙂
LikeLike
Thanks for responding so quickly Erich. Yes, the ScopeTrigger_Toggle task works as expected when Tickless Idle is disabled. When enabled it looks like somehow activity elsewhere is reducing some of the delays so that (a) some delays are less than they should be and (b) the tasks become synchronised.
I recognise that a simple project is called for and I will try to build that. The code I have now actually has 4 tasks (console task which sends commands to a state machine task, which sends commands to a Bluetooth task, which sends commands to the Bluetooth chip and also responds to the Bluetooth interrupt, before reading the Bluetooth response and sending the response to the state machine task which sends the response to the console task, which prints command/response values). So a bit complex for debugging I agree. All tasks except the console task were at tskIDLE_PRIORITY+1. I changed the console task priority from tskIDLE_PRIORITY to tskIDLE_PRIORITY+2 but this had no effect.
I have looked a the FRTOS settings you mention. In the Kinetis section SysTick was Enabled, Core Clock was set to “no” and Low Power Timer was Enabled. I changed Low Power timer to Disabled and the problem goes away: ScopeTrigger_Toggle Task executes at 1000ms always. Presumably that’s a clue.
One more radical result. I just stopped my console task from printing command/response messages (though the task still runs). The ScopeTrigger_Toggle Task now delays for as little as 14ms in sync with Bluetooth SPI and interrupt activity. So something associated with the SPI or Bluetooth interrupt seems to be corrupting the ScopeTrigger_Toggle Task delay. Why? Again, when I change Low Power timer to Disabled and the problem goes away.
LikeLike
Hi Charles,
so it seems there might be an issue with the low power timer then. Could it be that your interrupts cause overwriting some global memory (stack overflow)? I hope you have enough RAM, so could you increase the default stack size of the task in the FreeRTOS properties? E.g. to 300 if you have enough RAM?
LikeLike
I have calls to FRTOS1_uxTaskGetStackHighWaterMark() on all tasks and to FRTOS1_xPortGetFreeHeapSize() which show ample headroom. Also a trap on FRTOS1_vApplicationStackOverflowHook() which is not triggered. Anyway, the app does not crash – rather, it behaves OK, except that (maybe) on return from Tickless Idle the decision is made (incorrectly) that the ScopeTrigger_Toggle task is ready to execute. Can you point me at the code that makes that decision? What settings in the CPU PE component are needed to support the “Low Power Timer” in the FreeRTOS PE component?
I increased the stack to 350 for each task – no change.
As for my Bluetooth hardware interrupt, all I do is define the pin in PE as an edge-triggered interrupt then in Events.c I call FRTOS1_xQueueSendToBackFromISR() to notify a task that it should fetch the status from the Bluetooth chip. Is that OK? (I am not sure what is the recommended method for handling hardware interrupts in a FreeRTOS system – you might recall I suggested that a worked example would be very useful).
LikeLike
There is a decision hook you can use to decide for the application if it shall enter tickless low power mode or not. The setting is under the ‘Ticks > Tickless Idle Mode > Idle Decision Hook’ of the FreeRTOS component. I used that in https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples.
There is one imporant thing about interrupts with FreeRTOS and ARM, see http://www.freertos.org/RTOS-Cortex-M3-M4.html.
Is the hardware Bluetooth interrupt routine priority numerically equal or higher than the configMAX_SYSCALL_INTERRUPT_PRIORITY?
LikeLike
I’m sorry to bother you, I find here from google,
Because I recently tested with STM32 Fatfs, everything seems normal, but there is a small problem with my RTC date can not be more than 15 numbers, such as 16 will display number 0, would like to ask do you have any suggestions
Wade Lee
LikeLike
Which RTC are you using?
LikeLike
Hi Erich!
First, congrats for this great blog!
I’m having a problem with mutexes on MQX Lite, and I not found enough information about that.
Do you have a mutexes example, like a little tutorial?
Thanks,
LikeLike
Hello, thanks :-). I have not used MQX-Lite for while, because I moved all my projects to FreeRTOS. So I’m sorry, without digging again into MQX, I cannot help you right now.
LikeLike
Time and date: is there a PE component suitable for keeping track of the time and date, that will work with FreeRTOS, with tickless idle, on a KL25? All I need to do is to initialise a time and date then read it when I need a timestamp. I see “GenericTimeDate” and “TimeDate_LDD” both of which look more complex than I need. I’m not confident of the accuracy of a component that relies on counting RTOS ticks, especially given the FreeRTOS “Stopped Timer Compensation” parameter.
My hardware has a 32kHz crystal on the the EXTAL and XTAL pins, so this should be an accurate source, and I see that the KL25 has an RTC module that seems to be driven by a 32kHz crystal. But this seems separate from the OSC module. In the PE processor component the OSC System Oscillator 0 is configured for the 32kHz crystal but the RTC module is disabled.
I wonder if I should work with “GenericTimeDate” or “TimeDate_LDD”, or enable the RTC module and do my own thing?
LikeLike
The question is: how accurate do you need it? If you need something accurate (one minute drift per year) then I recommend a DS3232 (I have component for that). Or a DS1307 or similar.
I use both in combination with my GenericTimeDate component: I get periodically the accurate clock from outside (RTC chip, or from a radio time signal), and update the internal clock.
The GenericTimeDate component works very well with FreeRTOS (I use it with it): either feed the ticks from the RTOS tick counter hook, or use a FreeRTOS software timer. The FreeRTOS software timer has the advantage that it works easily with tickless idle mode. Using teh RTOS tick counter is little bit more tricky with tickless idle mode: you need to add the extra ticks in the ‘pre’ tickless idle mode hook. Otherwise simply use a normal timer (e.g. every 250 ms) and add the tick to the GenericTimeDate component.
I hope this helps?
LikeLike
Sir,
I am a great fan of your work. The bluetooth code helped a lot.
Now, I also need an RTC functionality.
So, do you have any RTC demo code on github?
That would be really useful for my project.
Thanks,
Parth
Freescale intern,
Austin, USA.
LikeLike
Hi Parth,
great, thank you! Yes, I use RTC functionality. But in my projects I’m using external RTC devices. See https://mcuoneclipse.com/2012/12/06/processor-expert-maxim-i2c-rtc-driver-the-arduino-data-logger-shield/. I use the DS3232 and the DS1307 (which is used as well in this project: https://mcuoneclipse.com/2014/07/27/led-clock-with-kitchen-hot-pan-protector/).
For this I use the GenericTimeDate component which only needs a periodic ‘addTick’ call.
Apart of that, my FatFS projects on GitHub use RTC too (for the file/date information on the SD card).
I hope this helps?
LikeLike
By coincidence I am working on adding an RTC to a KL15 design right now. (KL25 should be identical). The RTC_LDD PE component seems to be working (though I have not finished testing). I have a 32kHz crystal on the KL15 EXTAL pins, which I think will be a prerequisite – though I think the chip will accept an external RTC clock input. I think this should give good clock accuracy and should keep time when the processor is reset, asleep etc. In general, 32kHz crystals are more accurate than multi-MHz crystals.
I have found two surprises so far:
First – the processor will crash if you access RTC registers before enabling clock gating to the RTC.
Second – RTC1_SetTime() fails if the PE component “Enabled in init.code” setting is set to “no”.
I may post again when I have done more work….
LikeLike
Some more hints:
if there is a VBAT pin on the microcontroller, then using the RTC without powering it will crash (had to find this out the hard way).
And: If “Enabled in init. code” is set to ‘no’, then you need to call the RTC1_Init() function from your application.
LikeLike
Hi Eric,
Great blog.
I wonder if you can use all your Processor Expert components to target the Automotive Kinetis range?
Targeting this board would be great:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=TRK-KEA128
It has 12 analog channels and CAN, which make it really handy for me. At the moment I use 9S12X processors which are getting a bit old.
Thanks, Ian
LikeLike
Hi Ian,
thanks 🙂
I dont have that board. my latest S12 I used years ago was the S12XEP100 which I used with my compoents.
So, if there is Processor Expert support for that device, then my components shall work with it.
Erich
LikeLike
Hi Eric,
I have the DEMO9S12XEP100 board, but only ‘classic’ CodeWarrior supports it. So I thought to move to the new KEA128 chip to get the benefit of Eclipse.
Would you be interested in a loan board, to write a tutorial for your many readers?
Regards, Ian
LikeLike
Thanks for that offer. But my wife already tells me I need to have less boards ;-). that KEA128 board is not that expensive anyway. My concern is that as it looks like on workload, I would not have any time in the next 4-6 weeks anyway. And as it goes for CAN, I have no components used yet, apart the CAN ones which come with Processor Expert.
LikeLike
Erich,
Thank you again for great work on this site.
Is there a PE component that helps with FlexNVM on Kinetis devices?
LikeLike
Hi Moises,
I have not used FlexNVM, but I think you can use the normal IntFlash (Internal Flash) component for it.
Erich
LikeLike
Hello Erich,
OK. I will give the IntFlash a try.
Thank you for your help.
LikeLike
I was trying to figure out if a MK60FN1M0VLQ12 with the PGA could read a thermocouple? I spent an hour trying to post at Freescale but their ‘Gateway’ keeps dying.
LikeLike
I think this is not MK60 specific at all: it all depends on your termocouple interface you want to use.
LikeLike
As far as I can tell (just leaving Microchip land) the PGA and 16 bit ADC is a must for reading TC devices, the standalone devices have what FS has added to their parts. I also found RX62G and ST32 F3 with PGA, RX62G never heard of them, ST32 F373 slow and only 256K memory. I have not found any application notes about these integrated parts.
LikeLike
The web site is up and I found AN4508.pdf for the K53. I needed 6 channels for 6 thermocouples so neither ST or FS has a single chip solution as far as I can tell. The K53 looks to be weeks of fun…
LikeLike
Hi Eric,
You’ve been a great help to us in the past with USB issues and we have a new one that we’d like to pick your brain with.
We’re having some issues with the HID class on USB. Our communications link is custom: An MQX USB host is talking to a Device with the Freescale Bare Metal USB Stack using PEx. We chose HID because it seemed to be the easiest way to get going with USB. Most of the time the Device sends relatively small packets to the Host, up to 16 bytes. We have had not problems with that pipe.
When the Host needs to send control info to the Device we planned to use the HID Control Pipe. However, we’ve been getting errors in the data transfer over that path, particularly when the control packet gets up to 8 bytes.
What are our options to improve this situation? Is there a different class that would suit us better? Should we forego classes and add a new Host-to-Device data pipe to handle what is currently failing to work on the control pipe?
It would help our debugging if we could find a USB Protocol Analyzer. An external device would be hard to use with our hardware setup (no USB cables, only USB over a bus connection) and probably a bit too pricey. Is there a software solution that would run on a K60 or a K40 and could be embedded into either side?
As always, thanks for your time and expertise.
Greg
LikeLike
Hi Greg,
I managed so far to work without a USB protocol analyzer, but I feel more and more the need to buy one. Not sure what would be a good one, but I’m told that they might be very expensive :-(. USB HID devices are pretty simply, as not much functionality and very common. But I have not digged into all the details of these devices, and I was happy if things worked they way I wanted to have them. What I noticed at least with the USB CDC device stack was that in some cases, if the packet/data was 8 bytes or a multiple of it, that the packet was not sent. I had to send a dummy packet. I was never able to track the issue down, so not sure if this is a stack or a hardware issue. Search for ‘multiple of 8’ in https://mcuoneclipse.com/2013/08/29/usb-for-the-freescale-arm-kinetis-kl46z-and-k21d50m/
So not sure if your problem might be related to the same issue?
LikeLike
Erich,
I think the problem may stem from the PEx implementation of the HID Class. It only supports a Control Endpoint and an OUT endpoint. I am trying to use the Control Endpoint in place of what should by all rights be an IN endpoint and it isn’t working too well. I can’t figure out how to add another endpoint to the PEx HID component. Have you ever modified the PEx HID component to include an additional endpoint?
Thanks, Greg
LikeLike
Hi Greg,
no, I have not modified it to add an additional endpoint.
Erich
LikeLike
LTO is interesting topic.
How to use it and how to write code for better usage of it.
LikeLike
Yes, LTO (Link Time Optimization) is definitely a cool and promising topic. I have used that for non-GNU targets with some mixed results. Would need to look at the latest GNU implementation.
LikeLike
I tried, but did not achieve satisfactory results. It is possible that writing such code requires special approach.
LikeLike
Erich,
I thought I’d try my hand an modifying an HID bean to support another endpoint. I downloaded your library of component beans from github and installed them into my CWMCU 10.6. When I look at the alphabetical list of components I see many of the things in the list but not all. I see FSL_USB_Stack but not any other FSL_USB_* components. Do you have any idea where I might have lost them?
Thanks, Greg
LikeLike
Hi Greg,
they are there, but not visible on the ‘top’ level, as these components are only used as inherited sub-components. See https://mcuoneclipse.com/2014/08/12/hiding-a-component-in-cde/
Add the FSL_USB_Stack component, then you can select the sub-component.
I hope that makes sense.
LikeLike
Hi Erich,
I tried my hand at modifying your FSL_USB_Stack PEx component to add another HID subclass, defined as “KFConsole” (128) with a bidirectional protocol (adding endpoint 2). I made all the changes by hand, rather than use CDE. A lot of the modified PEx component seems to work but I can’t get it to generate code. Would you take a look at it and see if there is anything that is obviously wrong? (Let me know how to send you a zip file). I also have a few other questions regarding how you used the RingBuffer and the CriticalSection but first I need to get past getting PEx to make some code so I can test it.
Thanks!
LikeLike
Hi Greg,
is you application/code working? I mean you could do the changes in the generated code (Generated_Code folder), without overwriting it with new code generated. If that code is working, I can merge it back for you in CDE into the components so you can generate the code.
Erich
LikeLike
Hi Erich,
I took your advice and made changes to the Generated_Code in order to make a USB HID device subtype with both IN and OUT endpoints. Now that it is debugged can you help me to add it as a new subtype to your FSL_USB_Stack PEx component? I need to know how to send you the changed files.
Thanks, Greg
LikeLike
Hi Greg,
you can send it to the email address noted on https://mcuoneclipse.com/about/
Thanks!
Erich
LikeLike
Hi
Great blog! I found the FRDM with Arduino Ethernet Shield R3 really useful, I now have tcp connections going between multiple boards. It would be great if there could be a part 5 / library mod to maybe discuss the use of UDP packets rather than TCP. For certain embedded applications UDP is a better approach vs TCP.
Thanks
Jeff
LikeLike
Hi Jeff,
thanks for that suggestion. Yes, I had UDP in my mind too, but I did not need it (yet?).
Anyone else who could point to a good tutorial?
Erich
LikeLike
Click to access W5100_bootcamp.pdf
This was the only one I found after 20 minutes of googles
http://tools.ietf.org/html/rfc768 UDP RFC
LikeLike
DWARF4 and optimization level -Og ???
LikeLike
Step by step tutorial on LWIP will be nice…
Could be in 3 -4 parts…?
Thank you
LikeLike
Yes, agreed, that would be something very nice, and on my list for a long time already.
LikeLike
Hi Erich,
As I’m now finally got a project up and running with lwip + PEx (Your FreeRTOS component) and KSDK 1.2 I can share the main problems I faced … And there have been some 🙂
Just to help others to get over the hump of setting up such a project and maybe get some feedback on the decisions I’ve made ..
So maybe I can help getting this point from your list 🙂
I also can create a step by step guide, as this might help others to initially setup such a project and start from there.
Let me know if and how I can support your on this point.
Frank
LikeLike
Hi Frank,
any assistance/help you can provide on this would be highly appreciated. So a step-by-step guide would be great. With your permission, I can transform that into an article if you do not want to publish it on your own. And it would be great if that project could be shared (e.g. on GitHub) too. Let me know, and you can contact me as well directly with the email address listed on the About page of this blog.
THANKS!
LikeLike
What is a clean way of dealing with level-sensitive interrupts, in a KL15, PE, FreeRTOS system? I have a Bluetooth chip that raises an IRQ signal when it has an event to report – either as a response to a command I send it or asynchronously as Bluetooth network events occur. If the chip has one event then IRQ goes low when I have read the data. If it has more than one event then IRQ stays high after I read the data from the first event.
At present I have the IRQ pin configured as an edge-sensitive interrupt and in the Events.c ISR I call FRTOS1_xQueueSendToBackFromISR() so I can read the data later on. After I have read from the chip the data from the first interrupt, I poll the IRQ pin and if it is still high I do a call to FRTOS1_xQueueSendToBack() to flag that another interrupt is pending.
But this is inelegant and probably dangerous.
I don’t want to read and process the chip’s data within the ISR in Events.c.
I imagine there is an elegant solution but I can’t think what it is…
LikeLike
If I had a hardware AND gate between the two chips I could guarantee a second edge (so a second real interrupt) by gating off the IRQ signal until I had processed the first event. I tried a similar thing in software: First, I left the pin configured for rising-edge interrupts and then called xx_Disable() then xx_Enable() methods on the IRQ pin as I processed the data from the chip. That didn’t work (no second edge seen by the chip’s interrupt logic).
Second: I configured the pin for level sensitive interrupts then called xx_Disable() within the ISR in Events.c and xx_Enable() after I processed data from the chip. That does seem to work: I do get a second ISR triggered after the xx_Enable() when the IRQ pin stays high. So presumably the chip’s interrupt logic generates an interrupt if I enable the interrupt when the pin is already high.
Is this OK? It still seems rather a hack.
LikeLike
Hi Charles,
I just responded to your first question. And the approach with enable/disable might depend on how the hardware works. But from how I understand the KL15, if you disable the interrupts, and if you have a level interrupt, and then enable it, it will trigger an interrupt because at enable it will check the interrupt condition.
LikeLike
Not sure if I understand the full scenario:
a) interrupt goes high when data is ready
b) you set a flag (with the queue)
c) once you process the data (outside of the ISR in your application), the interrupt goes low (if there was only one data)
d) if in step c) there is a second data, the interrupt line stays high, until that second data is processed
If this is the case, I would check in step c), after you have retrieved the data, if the interrupt line goes low. Maybe for 1 ms or so, or whatever. If the interrupt line keeps high, I continue to read the data from the bluetooth transceiver until the interrupt line goes low.
so:
1) you get the ISR, set a flag with the queue
2) in the queue handling routine, get the data, then check the ISR line. If low, done. If high, continue to get the data (again).
I hope that works?
LikeLike
Hi Erich. yes, you did understand the scenario correctly. I think your polling idea and my polling idea both suffer from the risk that if we see the IRQ pin is still high (for event 2) we cannot be sure that it has remained high since the initial IRQ, or if it has gone low then high again. If it has gone low then high again then as an interrupt will be generated and we are in trouble: the code in the polling loop and the code from the second interrupt will both try to read data from event 2. I guess we could guard against that but it is getting complex.
The concept in my second post seems to work, and seems robust: when I re-enable the interrupt after reading data from event 1 there can be only one interrupt detected for event 2 – either immediately if IRQ has remained high, or later (even nanoseconds later) if IRQ has gone low then comes high. And the code goes through the same path for event 2 as for event 1.
Regards – Charles
LikeLike
Hi Charles,
yes, it would need some additional guarding (or realtime sychronization), I agree. Indeed, your second approach looks better to me now too 🙂
LikeLike
Topic: how to accommodate different PE hardware configurations with the same application source files?
I’m pleased to learn that ST Micro have released a PCB with their BlueNRG Bluetooth chip that will plug into a FRDM-KL25Z. Especially since that offers a development platform very close to my own KL15+BlueNRG board. See http://www.st.com/web/catalog/tools/FM116/SC1075/PF260517
You have to make a couple of hardware adjustments to ensure that their SPI port and interrupt pins end up on appropriate KL25 pins, but that is pretty easy. I’ve made the hardware changes and am about to port the software. Inevitably, ST’s choice of processor pin allocations are different from my own. (For example, for the SPI interface they use SPI0 pins on PTD1-3 and I have used SPI1 on PTD5-7) . I can accommodate this with different PE Components settings and my source files will not need to know.
The question is: can I keep a single Eclipse Project for more than one hardware implementation and swap between the different hardware implementations with something like a #define? Or am I forced to copy the code and PE components for the first hardware implementation into a new project, then adjust the PE components for the new hardware? That would work but then I have the problem of merging changes I make in the application source files back into the various copies in the different projects.
Ideally, I want something like this, in a single project:
#if HARDWARE1
use_ProcessorExpert.pe_for_hardware1
#else
use_ProcessorExpert.pe_for_hardware2
#endif
LikeLike
I appologize for the late response 😦
The answer is in one of my older posts (https://mcuoneclipse.com/2012/03/07/configurations-with-processor-expert/). I use Processor Expert configurations for this. It creates a #define for me which I can use in my application. I think this is exactly what you are looking for?
LikeLike
This is exactly the right answer! Also, I find that I can add two components with the same name (e.g. LED_Red, or AS1) but different settings (e.g. pin assignment and active high or low) then enable one in each configuration. Then the code remains identical between configurations – no need even to use the #define (in this case).
LikeLike
hey Erich,
Thanks a lot for this blog-it has been more useful to me than all freescale forums and support ticketsput together :). I used you USB CDC example for my old DemoJM board and they worked fine.
I recently bought the FRDM K64 board, but there is only one example on github, that blinks the rgb LED. I keep reading on your blog that if a project is written in PE it can be easily ported. Yet, to my embarrassment , I cant seem to do it. Do I need to do other things except changing the CPU and reconfigure the peripherals in order to port a PE project to a differnet cpu? Or there is more to it? I tried to port the FRDM K25 CDC USB code, but could not do it. I am mainly interested in the USB to virtual port (CDC USB).
Could you point to any resources that explain that in more detail? Or maybe, when you have time and if it’s not to difficult port one of the USB CDC K25/26 etc to FRDM k64 board?
I’m using CW 10.6 (updated )
Thanks,
Horia
LikeLike
Hi Horia,
I don’t really know the problem, but I have failed to use the 4.1.1 USB stack with the K64F Freedom board: it fails to enumerate. I suspect there must be something different in that chip, because previously porting to a new device was very easy: set up the clocks, setup the interrupt vectors and it works. I have spent again several hours on this, and it still fails. The USB CDC example in the Kinetis SDK works, but that stack is very different. I’m sorry, but I have not found a solution for myself yet 😦
LikeLike
Hey Erich , thanks a lot for looking into it. I guess I’ll just get a frdm k25 board for now :).
LikeLike
Yes, that will be much easier. The Tower boards are challenging as they have a lot of jumpers, and setting them wrong or without knowing the details of the schematics sets you up for failure.
LikeLike
Hi Erich, have you worked with ZLL (Zigbee Light Link) and ZCL (Zigbee Clusters Library) ?
I want to know if you can make a tutorial implementing this with Processor Expert, when you have the chance of course!
Thanks for your hard work, I allways use your page as a reference for my projects.
🙂
LikeLike
Hi Carlos,
no, I have not worked with ZLL and ZCL. All what I did was some ZigBee (with the FSL stack), but more with native SMAC and IEEE802.15.4 protocols.
Erich
LikeLike
Hi Erich – you might like to dedicate an article to the watchdog timer at some point. I have found that the Kinetis watchdog (called “Computer Operating Properly” or COP) is enabled after a reset. If you don’t add the PE Wdog component then it is disabled in Cpu.c:
/* Disable the WDOG module */
SIM_COPC = SIM_COPC_COPT(0x00);
But if the PE component is present this code is missing, even if the component is disabled! So the watchdog will reset the board. (bug or feature? See below.)
I also found that the SIM_COPC can only be written once, so there is no point in including the PE watchdog component and deciding to enable or disable the watchdog in your code (even using #defines): the only (pointless) thing you can do is to include the watchdog component then decide to disable it within the PE component. (You can do this by setting “Enabled in init code” to “no” and “Autoinitialisation” to “yes”, which creates a Wdog1_Enable() that disables the watchdog, then calls WDog1_Enable() from Cpu.c).
There also seems to be some kind of bug: I now find that I remove the watchdog component but Cpu.c still does not include the disabling code. ProcessorExpert.pe still contains several lines like this: WatchdogEnabled. I have been forced to disable the watchdog as described above. Grrr.
LikeLike
Hi Charles,
which microcontroller are you using? I have not faced such an issue on my side. The Watchdog gets disabled automatically by the CPU (at startup, during system init).
Only if I add the Watchdog component, it keeps enabled and then I feed the dog with the watchdog component.
LikeLike
KL05 on the Kepler IDE. I have subsequently moved the project back to CW 10.5 and confirm that (a) with the WDog component present but disabled (greyed out in the Components pane) there is no code present to disable the watchdog, and (b) the same applies if I remove it entirely. I don’t know how this has come about – some corruption of ProcessorExpert.pe? Puzzling, but not a show-stopper, as mostly I want to include a watchdog anyway.
I have just repeated the experiment with your KL05Z_FreeRTOS project. Before adding the watchdog component Cpu.c contains code to disable it. I added the watchdog component but left it disabled (greyed out): same code is present. I then enabled the component, leaving the default settings (enabled, auto-init off). As expected the SIM_COPC reference vanishes from Cpu.c and appears in Wdog1.c, WDog1_Init(). I then disable the component (greyed out), and the disabling code re-appears in Cpu.c. I can’t break it. I don’t know why my project is different…
LikeLike
Google doesn’t show a post on the Processor Expert RTC component, so I am posting these suggestions here…
I want to manipulate the RTC using raw seconds, rather than using the
LDD_RTC_TTime structure, because I want to do arithmetic on
the time: e.g. to calculate differences between timestamps t1 and t2, as well as store timestamps in flash memory, as differences from a reference time (for efficiency).
It would be good to add methods to the PE RTC component:
int32_t RTC1_GetRawTime(LDD_TDeviceData *DeviceDataPtr); // returns the RTC seconds register
void RTC1_GetTimeFromInt(uint32_t rawTime, LDD_RTC_TTime *TimePtr); // convert time in seconds to LDD_RTC_TTime form
Both of these can easily be created from the existing RTC1_GetTime() method – I’ve added these to my own code but don’t have the experience to modify the PE component.
Also: as far as I can see, the LDD_RTC_TTime structure uses 7 32-bit words to
store year, month, day, hour, minute, second and day of week. This is wasteful:
it is sufficent to use a 16-bit word for the year and bytes for the others (or a
byte for each if the year is treated as an offset from 2000). (I am getting paranoid about effciency as I am working with the KL05!). There is other unnecessary use of uint32_t in the RTC component, I think.
LikeLike
The LDD_RTC component is from Freescale, and therefore not modifiable. That’s why I’m using GenericTimeDate instead. I’m using it anyway with external RTC devices, and have not used the internal ones of the Freescale devices so far.
LikeLike
Can I report a bug here? There is a problem with level-sensitive interrupts. If you have two level sensitive interrupts on the same port with one of the signals in the active state, but disabled, then its interrupt event is triggered when the second interrupt occurs (even though it is disabled). I have analysed it, but don’t want to clutter this space with the analysis. It relates to not clearing the Interrupt Status Flag when the interrupt is disabled. The fix in my own code is something like this:
/* Disable interrupt in the _onInterrupt() code: */
Switch_IRQ_Disable();
/* Clear the interrupt flag or this ISR can trigger again if the another interrupt happens */
PORT_PDD_ClearPinInterruptFlag(PORTA_BASE_PTR, ExtIntLdd5_PIN_INDEX);
LikeLike
Hi Charles,
it seems to me that this is related to the issue I have described here:https://mcuoneclipse.com/2014/10/12/user-interrupt-on-nmi-pin-with-kinetis-and-extint-component/
? I don’t think it is related to level or edge sensitivity, but due the fact that there is only one interrupt for the whole port?
Erich
LikeLike
I’m having trouble setting up a variable frequency component on a processor expert freedom board. In the methods tab, I can’t enable the “SetPulseWidthMS” option. If I hover the mouse over it, it says the “Runtime Setting Type” must be set to “from Interval”. Where does one set this?
LikeLike
Inside the timing dialog, you can configure values to a ‘list of items’ or as well intervals.
LikeLike
how can we use cpp and newlib with freertos and freertos’s heap in kds?
LikeLike
Kevin,
why should this not be possible?
Erich
LikeLike
Hi Erich,
Do you have the time to make a simple howto for Design Studio 2.0 and processor expert? I’m very stuck at the moment. I’m trying to blink an LED on the kl46z board. I can see in the processor expert SW that LED2_RED is defined and attached to a pin, but from there I just get symbol not defined errors when I try to use it.
I don;t have GPIO_LDD as a component in the PE software either. Have a really nedded up the install, or have things changed drastically since DS 1?
Regards,
David
LikeLike
Hi David,
things do not have dramatically changed. Yes, some UI elements are different, but not that much. It might depend what project you have created. For the Kinetis SDK?
I wish I could find some time for that tutorial, I have too many things piled up right now. Let me see what I can do. Hopefully I can create a tutorial in the next days.
Erich
LikeLike
Hi Erich,
Thank you for your reply. I shall check the project type this evening when I’m back in the lab.
David
LikeLike
Hi Erich,
I’ve documented what I’ve done so far here:
http://webshed.org/wiki/FRDM_KL46Z_Blink
Is there anything really obviously wrong?
David
LikeLike
Hi David,
I see you have used/selected the Kinetis SDK during project creation. This is a completely different driver model.
See
The easiest would be if you do not use the SDK, but you go with a normal Processor Expert project. Then all my previous tutorials still apply.
Erich
LikeLike
Erich,
I have a question about control of the USB stack. I’m using a modified form of your PEx USB device component: FSL_USB_HID_Mouse_Device.
I have hardware that connects to two different USB hosts, with a hardware switch to select which one to use.
When I switch between hosts I’ve found that simply switching the lines is not enough, but I must also tell the stack that it has to enumerate with a new host.
I’ve tried to reset the stack by using: USB_Class_HID_DeInit(), then switching the hardware, and finally restarting the stack with USB1_Init().
This seems to work some of the time but also has also caused CPU restarts (PE_ISR(Cpu_ivINT_Hard_Fault).
Am I on the right track in doing this?
Thanks, Greg
LikeLike
Hi Greg,
for sure I have not used it in that way.
Are you able to identify the location causing the hard fault?
See
Erich
LikeLike
Thanks for the clue, Erich.
Tracing the source of the Hard Fault got me much deeper into the USB driver than I ever thought I’d be. Thanks for making that possible.
It seems that De-Initializing USB takes a very long time to complete. Waiting 200 msec wasn’t enough.
If I wait 1 second after issuing the De-Init command before I issue a new Init command, everything works as intended and I can switch from one USB host to another one.
Greg
LikeLike
Erich,
I have a little more information about the De-Init problem that leads to the Hard Fault exception.
After playing with it some more I believe that the problem is due to a race condition. It gets better with long delays between De-Init and Re-Init but it doesn’t go away entirely.
It seems that the De-Init clears many stack definitions, including the Bus Reset Callback address. If that address is still cleared when the hardware issues a Bus Reset, the stack attempts to execute the callback at the now cleared address, resulting in the Hard Fault.
I don’t know enough about the inner workings of the USB stack to know how to fix this, but I suspect that it would involve either holding off the clear of the callback address until after the bus reset occurs, or inhibiting the bus reset after the callback address is cleared.
Can you help to resolve this?
Thanks, Greg
LikeLike
Hi Greg,
hmm, it might be that during DeInit() interrupts are still enabled. I think I need to properly do the de-initialization with interrupts disabling.
Do you think too that could be the reason?
Erich
LikeLike
Hi Greg,
I have added Deinit() functionality in the USB Stack and I have sent you that components by email. Can you check it out? Sources are on GitHub, and if everything goes right, these changes will be in the next *.PEupd version.
Thanks!
Erich
LikeLike
Erich,
USB1_Deinit() has fixed the problem (at least in the first 50 tries).
Also, I no longer need a long delay between Deinit and the subsequent Init.
Thanks so much.
Greg
LikeLike
Hi Greg,
Excellent! Thanks for reporting that problem. It is always difficult to forsee all the different use cases. I’m glad that the components are now able to handle your case too. The changes will be included in the next *.PEupd release.
Erich
LikeLike
Hi Erich,
Do you have any I2S library for codewarrior?, Or Do you know a way to make it with microprocessor expert?
Thanks, you very much
Paco
LikeLike
Hi Paco,
no, I have not used I2S, so I don’t know, sorry.
Erich
LikeLike
Hi Erich, Would be nice to read a tutorial on how to use cheap 160×128 displays with ST7735 driver which are available for less than $5 on ebay. I used it with AVR, but I would like to see it functioning with PE graphic components such as GDisplay, GFont…
LikeLike
Hi Ondrej,
thanks for that suggestion. So I first would need to organize such a display and the time for it. Will see what I can do.
LikeLike
Hello Erich,
Could you make a tutorial on using nRF8001 with a Kinetis microcontroller?
LikeLike
That one:
http://www.adafruit.com/product/1697
? I have it on my shelf, but no time yet apart of some first initial trials.
LikeLiked by 1 person
Yup, this one. I am looking forward to the times when you will have time for this 🙂
Until then, good luck with the things that you are currently working on!
LikeLike
I have a question concerning the MC56F84763.
I am using the DMA3 peripheral in tandem with the QSCI block.
I have an array of uint16_t variable types that I fill with data periodically (triggered by a timer ~300ms). I point the DMA3 to the address of the QSCI and the address of the array and trigger the DMA3 to run. Once the DMA3 is completed (sends all the data), I manually stop the transmitting of the DMA in an interrupt.
Once the timer hits again, I re-fill the array of data, reset the DMA3 to the right addresses and trigger it again.
The result is that whatever is at the beginning of the array is transmitted multiple times. Once this glitching of transmitting multiple times is done, the entire message is sent in completion and is correct.
I would like to get rid of the glitching at the beginning of the message entirely. When I debug, the array is populated correctly and has the correct information, the correct number of times, and in the correct order.
I have a powerpoint which has pics of my initialization components in PE, some code snippets, and the results (the glitches).
Lastly, I am getting a situation where infrequently the entire messaging system completely locks up and no UART data is transmitted at all. This happens even though the rest of the processor is working fully and all other functionality is there. Basically, it looks like the UART transmission is completely locked up.
LikeLike
Hi Dan,
I’m sorry that I cannot help you: I moved away from the DSC because to me the new ARM Cortex devices had a much better performance/feature/price ratio.
What you describe could be as well a glitch or bug in the silicon. Have you checked the device errata about this?
LikeLike
I’ll check that out and report back. Thanks!
LikeLike
Can I program earlier .elf images from within Kepler using JLink (so I can keep and use an older version while continuing development)? The Kepler Debug interface doesn’t seem to allow this.
Or can I use JLink without Kepler? I have tried the JLink.exe command line – but it is a bit clunky: I have to set the device type, then erase, then use the loadbin command (which in turn means I have to change the linker output file format to Raw Binary). Is this the best I can do?
LikeLike
Hi Charles,
yes, you can select any binary to program it with J-Link under Eclipse. If I understand it correctly, you just want to keep the .elf (kind of as the ‘working’ binary) and continue development? And yes, you can use J-Link standalone too, with the segger gdb debugger/command line interface. And you do not have to change the linker file to produce a binary file: you can use the ‘create flash image’ option in the panel: https://mcuoneclipse.com/2014/04/20/binary-files-for-the-mbed-bootloader-with-eclipse-and-gnu-arm-eclipse-plugins/
LikeLike
Hi guys,
My name is Maria, I have a problem, I’m trying to program to program a teensy 3.1 for which I use codewarrior to create the hex, and load it to the chip with teensyloader. The problem is that the iHex file that codewarrior is not recognize by teensyloader. How can I fix this probem?
Thank you very much
Maria
LikeLike
Hi Maria,
see https://mcuoneclipse.com/2015/02/14/quick-way-to-open-closed-project-in-eclipse/#comment-50926
Erich
LikeLike
Hi Erich,
I don’t understand, what’s the relation between my problem, Could you explain me a bit more in detail?
Thanks,
Maria
LikeLike
Hi Maria,
C.R. has asked exactly the same question as you did here, and I posted an answer there. Have you seen it?
Thanks,
Erich
LikeLike
Hi Erich,
where can i buy a j-link lite fsl ?
I can not find a link from freescale website.
LikeLike
Hi Kevin,
I think it is not sold separately. I had mine with a K60 Tower kit:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=TWR-K60N512-IAR&tid=m32TWR
LikeLike
Too bad 😦
LikeLike
Hello Erich,
I’d like to ask you if you could guide me on how to use multiple clock configurations within code and setup those with PE (KDS).
Use case would be to use fast internal oscillator to clock both: core and bus with 4[MHz] (4[MHz] bus for fastest SPI communication) in normal run mode.
While in low power mode clock with 1[MHz] derived from fast internal oscillator and lower bus clock to 250[kHz] for lowering power consumption (SPI not used).
Return to normal run should be on some timer interrupt for example every 60[s] (systick or timer unit).
Is it possible as core clock in low power modes is off?
Thank you in advance for your hints.
LikeLike
Yes, I have something similar like this, see https://mcuoneclipse.com/2013/10/20/tutorial-using-the-frdm-kl25z-as-low-power-board/
There is a link to the project at the end of that article (CodeWarrior project).
I hope this helps.
LikeLike
Erich,
If I may plug my own code? I have written a small font engine for embedded platforms that I have uploaded to sourceforge. ( http://sourceforge.net/projects/portabletypeengine/ ) I have been using it with a Freescale processor and it seems to be quite small enough and fast enough for use with sub 100MHz processors.
However, it is a lonely project because no-one knows it’s there 😦 Perhaps you’d like to have a quick look and see if you want to add it to your excellent code library?
Many thanks,
Matt.
LikeLike
Hi Matt,
sure, give me a few days to check out what you did.
Erich
LikeLike
Hi Erich,
I’m back playing with your HID class driver (using your USB beans updated 4 Feb 15)
When I have an enumerated connection and I want to disconnect, using USB1_Deinit() (which returns success), and then check if I have become de-enumerated, with a call to HIDM1_isEnumerated(), I do not receive a response that says I am not enumerated (even after delaying up to 20 sec)..
Is there something else I have to do to reset the stack?
Thanks, Greg
LikeLike
I would need to check. It has been used only in the context of Deinit() and then doing an Init() later on.
LikeLike
Yes, Erich, that’s also what I’m doing.
I have a USB switch that selects between two hosts.
When I’m connected to one host and then want to switch to the other I perform a DeInit(), switch the connection and then perform an Init(). However, if the first connection never becomes de-enumerated then the stack thinks the second connection is already enumerated before it actually is. This is particularly obvious when there is no host on the second connection, yet the software says it’s enumerated.
LikeLike
Hi Greg,
I have made several extensions to the USB HID Keyboard and USB HID Mouse components which now hopefully are able to do what you want and need. At least with my testing it works now: I can Init() and DeInit() the USB properly. If you want, can you give it a try? I have commited the changes on GitHub, especially in this commit:
https://github.com/ErichStyger/McuOnEclipse_PEx/commit/b83e9b03e29c1e3ab987d014ee779eb281c83c07
I hope this helps,
Erich
LikeLike
Thanks, Erich.
It took me a little time to test.
Your fix is successful. I can now deinit from one USB port and then switch to another.
Thanks a lot.
Greg
LikeLike
Hi Greg,
no problem. I took me a little time too to get it done 😉 Erich
LikeLike
Just start a new project and decided to own load and install Kinetis Design Studio V3.0.0 ….
It is ‘different’ the whole ‘Tools’ tab is gone. When I tried to install KSDK I couldn’t get JAVA to stop asking to be installed with IE, Chrome doesn’t support JAVA but finally Firefox worked.
Please go through an install of Kinetis Design Studio V3.0.0 with adding all the parts needed to make it functional.
Thanks for the KL02 project!
LikeLike
Hi Kevin,
I have not faced such issues. Maybe you can post that in the Freescale forums?
Erich
LikeLike
I have a Arduino Project and i’m using the XBEE.
Would you for a cash fee consult me on using nRF24L01 modules.
LikeLike
Hi Bryan,
you are always free to donate something for the students, but I do not offer paid services like that. Be free to ask any questions, and I try to answer as much as I can.
LikeLike
Hello. I wrote a comment under your “Unboxing KL43Z” article. Thank You for your prompt answer 🙂
Moving on to my kind request – are you able to direct me (and other readers) towards an article/tutorial that will show how to use LCDs interfaced on SPI? Preferably a SSD1306 one. I have big difficulties with it, since there are no tutorials available for SPI interfacing (or at least I have not found one) and the popular u8glib seems to be not working in KDS 😦
Thank You so much in advance!
LikeLike
Hi Peter,
I do not have a SSD1306, but I have used the TWR-LCD or the SSD1289 displays.
In my experience, it should not be too hard. But there are so many different displays, and I only can share as much as I have done in my projects. I have not used u8glib, as using a simple driver (at least for me) was always easier than porting a huge set of libraries. I think you need to understand the display commands, than it would be pretty easy to write a simple driver? As for the high level drawing routines and graphics, I have several Processor Expert components devloped including components for GUI (windows, buttons, etc) and touch screen support.
LikeLike
I am trying to use a K64F dev board to run a relay board that requires 5V to switch the relays. Is there any way to get the digital outputs to work at 5V?
LikeLike
Hi Jon
If you connect the top of the relay’s coil to +5V and the bottom of the coil to a processor pin then the processor pin will be at 5V – a small number of processors are designed to cope with this but most are not. The GPIO pin at 5V will actually drive the processor’s 3.3V supply rail towards 5V, through ESD internal protection diodes within the processor. Bad news. (This is actually a general issue that can arise when two parts of a circuit are at different supply voltages – and can often happen when one PCB is powered off but remains connected to a second PCB that is still powered).
It’s easiest and safest to have the processor drive the base of an NPN transistor (through say 10k resistor) with the emitter to GND (0V) and the collector to one side of the relay coil. Then the other side of the coil connects to +5V. Drive the GPIO pin to logic 1 to pass current to GND through the base-emitter junction and turn on the transistor and relay.
Some other points:
1 Check there is not a pull-up resistor enabled by default on the processor GPIO pin (I have not checked this processor to see) – if there is then your transistor will turn on by default at reset. If so you’ll need to tweak the circuit – e.g.cascade a PNP transistor with the NPN. You should ensure your software has to perform an explicit operation to turn on your relay.
2 You could use an N-channel MOSFET instead of the NPN transistor, but you may have to add a resistor to GND (on the processor-gate node), since otherwise the processor-gate node will be floating, and leakage current may take that node above the turn-on voltage before your initialization code sets the GPIO pin as an output. No floating nodes!
3 Always remember to think about the circuit state at power-on and at any other reset event, and be sure your external circuit will always be in a safe state.
4 Add a reverse-biased diode across your relay coil. When your transistor switches off the collapsing current in the relay coil will produce a high reverse voltage which could damage your electronics (V = L (di/dt) if I recall…..). The diode permits the decaying current to circulate to the +5v rail safely.
LikeLike
Charles has that question better answered than I could have 🙂
LikeLike
Thank you for the great information, it is very thorough! Right now I am using a level converter instead of modifying the board. I am not sure what the permanent solution will be or when the next iteration will happen, but I will let you know if I try your suggestions above and how they work out.
LikeLike
For the last few years I have been using the VN5160 as a high side relay on my MCUs. It will switch 4.5V to 36V at up to 5 amps. This means I can use 5V on my test and development setup and then connect it to multiple 24V relays in position with no change over.
The VN5160 comes in the SO-8 surface mount package so it is easy to solder by hand. Be sure to read the thermal data section of the data sheet to learn how to design a PCB which will dissipate heat if you are driving a lot of current. (It is not too hard to make your own PCBs if you use PCB Fab-in-Box [pcbfx.com].)
LikeLike
Hi Eric,
I’am using Kinetis, and TermComponent
I set the ‘enable interrupt’
But i’dont know, how is setup interrupt function
i want to take a char on rx with interrupt service routine
How i do this,
Thanks My Regards,
LikeLike
Hi Onur,
You don’t have to setup any interrupt function(s), it will be managed by the component. If you call a function like SendStr(), it will place it into a buffer, it will be sent with an interrupt. Same for receiveing data: it will create interrupts and the data will be placed in a buffer. Read the buffer with ReadChar(). Use KeyPressed() to check if there is something in the buffer first.. Make sure you allocate some bytes in the component settings > Interrupt service/event > Input buffer size and Output buffer size). Use buffer sizes what you expect to send/receive in a single chunk/interrupt. I use values of 64 or 32 at least.
I hope this helps?
LikeLike
I am using the FSL_USB_STACK Processor expert component with MQXLite.
I had to tweak little bit with vector configuration.
With this now USB Enumeration works, and I am able to see the “virtual com port” on PC.
But now this screwed up with MQXlite itself, none of the tasks are running.
It is in loop all time in function “_pend_svc” at below location in dispatch.s file
ASM_LABEL(find_noempty_que)
ldr r2, [r1, #0] /* address of first td */
cmp r2, r1 /* ready_q structure itself? */
bne switch_task
ldr r1, [r1, #RQ_NEXT_Q] /* try next queue */
movs r1, r1
bne find_noempty_que
/* r1 is 0 -> empty */
ASM_LABEL(no_one_to_run)
/* TODO set system task ??? */
/* enable all interrupts (r1 = 0) */
/* TODO maybe (maybe not necessary) restore PendSV priority and BASEPRI after wfi */
msr BASEPRI, r1
ldr r1, =0xE000ED20 /* SHPR3 */
ldr r2, =0xff
strb r2, [r1, #2]
/* wait for interrupt */
cpsie.n i
wfi
cpsid.n i
LikeLike
Hi Niranjan,
I’m not using MQXLite any more, and switched all my projects to FreeRTOS. So I’m not sure what MQXlite is doing here, but I can say that there is no problem with FreeRTOS. Maybe you can consider using FreeRTOS instead too?
LikeLike
Hi Erich,
really great work on this site, thank you!
I am evaluating the sensor fusion toolbox (https://mcuoneclipse.com/2015/10/09/kinetis-drone-sensor-fusion-toolbox/) and I want to add an LCD (https://mcuoneclipse.com/2012/12/22/hd44780-2×16-character-display-for-kinetis-and-freedom-board/) to show some information.
Unfortunately when I have the LCDHTA module enabled, the program crashes somewhere in PE_low_level_init().
The LCDHTA module with exactly the same configuration works fine in another project, but this is without MQX.
Do you have an idea what the problem might come from? I’m quite new to RTOS, maybe there is something I have to configure in a different way compared to a non-RTOS project?
Best regards,
Julian
LikeLike
Hi Julian,
I suspect a hard fault caused by some wrong memory access (but hard to tell the details). Using an RTOS or not should not make a difference. Can you check where the fault is happening? This component might help you to locate the program counter position: https://mcuoneclipse.com/2012/12/28/a-processor-expert-component-to-help-with-hard-faults/
I hope this helps.
LikeLike
Hi Erich,
thanks for your fast reply.
It seems there is no hard fault, so I stepped into PE_low_level_init(). When stepping over the three calls inside, I return to main(). This is not the case if I step over PE_low_level_init(). Anyway, if I step through the following calls in main(), it still happens that the MCU is suddenly running and not halting again. Hitting the pause button then shows, that the MCU is spinning in the dispatcher. In dispatch.S at ASM_LABEL(find_noempty_que), then ASM_LABEL(no_one_to_run) and then back to ASM_LABEL(find_noempty_que).
I am using the K64F board with STBC-AGM01 on top. The project is taken directly from the sensor fusion 5 package. The only thing I changed is that I disabled the MPL3115 part.
LikeLike
How many breakpoints have you set? Keep in mind that the number of hardware breakpoints is limited, so if you have too many breakpoints active, stepping will be impacted.
LikeLike
I have no breakpoints set (only the temporary one on main). When the MCU is not halting again, it’s also not running the program as it should. Usually I have the green LED on the K64F board flashing when it works correctly. It also doesn’t if I run the program directly without stepping.
If I disable the LCDHTA module in processor expert, everything works as it should, but of course without LCD.
LikeLike
Hi Julian,
You need to step through your code to find out why and where it is having that problem. You need to use the debugger for this. It could be that the LCD driver is waiting for the LCD to respond, but the LCD somehow does not provide an answer.
LikeLike
Hi Erich,
I found the command causing the problem. It’s
CPU_SetBASEPRI(CPU_INIT_PRIORITY) in CPU_Init.c. CPU_INIT_PRIORITY has a value of 0xF0U by default (PE generated). Changing it to 0x70U for example makes everything work.
But I can’t tell why the default value causes problems or which setting in the MQXLite PE module leads to this value… do you have an idea?
LikeLike
Found it in the CPU settings. It’s the initialization tasks priority.
LikeLike
What’s the latest on PE support for touch sensing on Kinetis processors? If I recall it wasn’t supported very well. I’m interested in capacitive sensing of liquid levels – google suggests Freescale has worked in this area…
LikeLike
Hi Erich,
Can you please give a guide to port AN4379 (USB MSD ) Bootloader to MK22DX256VLF5 .I am a complete newbie to CW tools tried to follow the pdf but I am getting compilation errors ,if not specific to my MCU can you give a generic guide for porting bootloaders to any common mcu (for example the MCU of FRDM kl25z board ).
LikeLike
Hi Erich
In a quest to be able to predict an ARMs behavior I like to count the cycles for each instruction in my code and compare with an oscilloscope. I use FRDM-KL25Z board and Kinetis Studio software.
My code is like this:
int main(void)
{
SIM_SCGC5 |=0x400; //enable clock to port B
PORTB_PCR19 = 0x100; //Make PTB19 as GPIO
GPIOB_PDDR|=0x80000; //Make BTB19 as output pin
while(1)
{
GPIOB_PDOR &= ~0x80000; //turn green led on (pin low)
GPIOB_PDOR |= 0x80000; //turn green led off (pin high)
}
return 0;
}
Which compiles to (just the while loop):
while(1)
{
GPIOB_PDOR &= ~0x80000; //turn green led on
548: 4b09 ldr r3, [pc, #36] ; (570 )
54a: 4a09 ldr r2, [pc, #36] ; (570 )
54c: 6811 ldr r1, [r2, #0]
54e: 4a09 ldr r2, [pc, #36] ; (574 )
550: 400a ands r2, r1
552: 601a str r2, [r3, #0]
C:\Users\baldurtho\workspace.kds\TestProject_005\Debug/../Sources/main.c:87 (discriminator 1)
GPIOB_PDOR |= 0x80000;
554: 4b06 ldr r3, [pc, #24] ; (570 )
556: 4a06 ldr r2, [pc, #24] ; (570 )
558: 6812 ldr r2, [r2, #0]
55a: 2180 movs r1, #128 ; 0x80
55c: 0309 lsls r1, r1, #12
55e: 430a orrs r2, r1
560: 601a str r2, [r3, #0]
C:\Users\baldurtho\workspace.kds\TestProject_005\Debug/../Sources/main.c:90 (discriminator 1)
}
562: e7f1 b.n 548
564: 40047000 .word 0x40047000
568: 00001038 .word 0x00001038
56c: 4004a000 .word 0x4004a000
570: 400ff040 .word 0x400ff040
574: fff7ffff .word 0xfff7ffff
This code gave a square wave on the oscilloscope of 717 ns High and 618 ns Low.
To check my clock period I added 10 „nop“s and found it to be about 47.7ns.
So from the code without nops the 717ns is equivalent to 15 cycles and 618 is equivalent to 13 cycles
Low period: Counting cycles from line 552 (pin set low) to line 560 (pin set high) I count (my comments in the brackets) 11 cycles when scope said 13.
High period: counting cycles from line 560 to 552 i find 14 cycles but scople says 15
I have read that the m0+ processor has a 2 stage pipeline. Due to it I thought maby the four 2 cycle instructions in row at line 548 to 54e would actually execute on every cycle and thus my actual program (oscilloscope) would be faster than the cycles for each instruction. But what I experience is the opposite, my code is slower than predicted.
How are instructions time evaluated for ARM m0+?
Best regards,
Baldur
LikeLike
Hi Baldur,
very interesting findings. Unfortunately, I’m not of much (or any?) help here.
For my WAIT component I have simply used a rough experimental measurement for the tuning. But there I only wanted to be in the 10% range.
I think branching could impact your measurement. What if you unroll the loop? And instead doing load/store, just have many NOP’s and only few load/store for the LED toggling in between?
LikeLike
There is on some Cortex-M4 a cycle counter register (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0439c/BABJFFGJ.html), but I believe that does not exist on M0+.
LikeLike
Hi Erich
and thanks for your comment. I did not get much out of it though 😦
I did some more experiments:
1) added a NOP instruction to my C code in inline assember just after I turn the LED on. This increased the low period from 618ns to 667ns or one clock cycle (this I can understand as this is a one cycle command)
2) I added an inline assembly command:
__asm(“ldr r3, [pc, #28]”);
this changed low period from 618ns to 715ns or added 2 clock cycles (OK, this is a 2-clock cycle command as can be seen here: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0432c/CHDCICDF.html)
3) I added two __asm(“ldr r3, [pc, #28]”); in a row and this changed low from 618 ns to 811ns, that is added 4 cycles.
This result puzzles me. If we have a pipeline of length two, should the fetch of second command not be done in the execute part of the first command (and thus the second command work as a single cycle command?
Maybe the cycles per instruction given in the ARM table is when taken into account the pipeline – is that possible?
Another thing could be wait states in the memory access, but I read that the KL25Z had zero wait states (page 36 in KL25 Sub-Family Reference Manual). Do you understand this the same way?
LikeLike
Hi Baldurt,
to me, all what you say makes sense. Maybe best if you ask that question in the Freescale community forum (freescale community /kinetis) as this requires some insights from the silicon designers?
LikeLike
How should I proceed with development with the Kinetis KM processors? Is support missing from Processor Expert? These are inexpensive processors with high-performance analog front ends – intended primarily for electricity meters but presumably useful for other analog instruments (see Freescale’s AN4853).
LikeLike
Support for KM is missing both on the Kinetis SDK and Processor Expert side. From a support perspective, they really look like orphaned somehow. I have not worked with the KM family yet, so no real experience with them. The question will be: from where to get all the drivers and software? FreeRTOS is not a problem, that would work on any M4 or M0+, but the drivers e.g. for that analog peripherals, not sure from where to get them.
LikeLike
You can use bare-metal drivers:
http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/kinetis-cortex-m/m-series/high-accuracy-analog-front-end-lcd-microcontrollers-mcus:KM3x?fpsp=1&tab=Documentation_Tab
Related File: KMSWDRVAPIRM_SW.zip
Drivers come with documentation (readme.html), with over 80 examples, make_project command line utility, bare-metal and FreeRTOS support.
LikeLike
Hi, Erich,
How to use the freertos trace component with ksdk1.3_freertos,
i just add the trace component and add the line in FreeRTOSConfig.h,
but get lots errors while compling.
How to use the component in a easy way with ksdk freertos
LikeLike
Hi Kevin,
are you using the McuOnEclipse FreeRTOS component?
Erich
LikeLike
Hi Kevin,
in addition to my previous reply: have a look at my FreeRTOS with lwIP project described here: https://mcuoneclipse.com/2015/10/28/tutorial-lwip-with-the-freertos-and-the-freescale-frdm-k64f-board/
Check out that project on GitHub (link in the article). That project is using and configured to use Percepio trace with Segger RTT.
I hope this helps.
LikeLike
Hello Erich,
I am using K20 MCU. I want to upgrade application firmware Over the Air (OTA). I have done all functionality GSM/GPRS, Communication over TCP/UDP etc. What I am looking for is Firmware upgrade over the air. Can you suggest me How to accoplish this ?
Thanks in advance!
LikeLike
Hi Rob,
OTA firmware upgrade is not any different than firmware upgrades over UART, USB, MSD, CAN, etc: all what you need is a communication protocol which handles the traffic of the data with the needed consistency checks. Because OTA means that it might take a while until the image is transmitted, usually the bootloader stores the data in a shadow flash or external memory device.
LikeLike
Hi Erich,
may I suggest to add a “typedef unsigned char byte” in PE_KSDK_Types? In a KSDK project it is (yet) needed to use your Utility component in the declaration “byte UTIL_strtailcmp(…”
Thanks again for your great work!
Best regards, Michael
LikeLike
Hi Michael,
that was an oversight on my side :-(. I have already made a fix and commited here:
https://github.com/ErichStyger/McuOnEclipse_PEx/commit/8fcdba2e67decf63dc9e1f1e6818d3cf70a7985d
You might as well directly patch the Utility driver code on your machine if you cannot wait for the new release. Let me know if you need help on that.
Erich
LikeLike
Hi Erich, I am already ok.
Thanks again, Michael
LikeLike
Erich, I am using KDS3.0 with KSDK1.3 & KSDK1.2 installed. When I try to make an SDK project and select the MK10DX128XXX7 there is no SDK selection option. The KDS selection box says “None” and is greyed out.
The document KDS300RN states on page 8 that SDK1.2 supports the MK10DX128xxx7. What’s up, how can I fix this?
B.K.
LikeLike
Hi Bob,
The C:\Freescale\KSDK_1.3.0\ksdk_manifest.xml lists the devices supported, and I see that the MK10DX128xxx10 (100 MHz part) is listed. Not sure how compatible the 72 MHz part and the 100 MHz parts are, but you might try that one?
Erich
LikeLike
I can select the MK10DX128xxx10 but only the 144 pin packages are supported. The 50Mhz part only supports 121 and 80 pin parts. I am using the 72Mhz, 32 pin MK10DX128xxx7.
LikeLike
Hi Bob,
checking the Kinetis SDK it looks like that DX128 part is not supported. You might tweak one of the other existing parts, but that’s for sure some extra effort.
LikeLike
Hello Erich,
I have set a KDS3.00 / KSDK1.3 / FreeRTOS v8.2.3 / MK22FX512xxx12 project with Segger System View and Trace Facility enabled (13/01/16 components release). However, building returns the error “undefined reference to `xEventGroupSetBitsFromISR’ fsl_os_abstraction_free_rtos.c line 372”. I checked and the code generation of this method is enabled. Do you have some suggestion to where I should look?
Thanks, Michael
LikeLike
Hi Michael,
in order to have xEventGroupSetBitsFromISR() enabled, you need to have have the following defines turned on (in FreeRTOSConfig.h):
configUSE_TRACE_FACILITY
configUSE_TIMERS
INCLUDE_xTimerPendFunctionCall
So do you have the trace functionality and software timers enabled?
I hope this helps,
Erich
LikeLike
Hi Erich, straight to the target 🙂 I was just missing the TIMERS enable.
Thanks, Michael
LikeLike