I wrote a program for blinking LED. The program does not work:
#include "Cpu.h"
#include "Events.h"
//#include "Bit.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
void opz(int ile)
{
int p;
for(p=0;p<ile;p++)
{
}
}
void ledkonf(void)
{
PORTB_PCR18=PORTB_PCR18 &~(1<<10) &~(1<<9) | (1<<8);
GPIOB_PDDR=GPIOB_PDDR | (1<<18);
}
void swiec(void)
{
opz(100000);
GPIOB_PDOR=GPIOB_PDOR|(1<<18);
opz(100000);
GPIOB_PTOR=GPIOB_PTOR|(1<<18);
opz(100000);
}
int main(void)
{
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
ledkonf();
for(;;){
swiec();
}
}
But when I added element BitIO_LDD in the Processor Expert, the program works, and the only new element of the program is generated file Bit.h. When I create a project without Processor Expert, the program does not work either. Why is it like that? Please help!
已解决! 转到解答。
Hello,
Please take a look into the thread below, specially the post marked as correct answer. It explains how to get a LED and a push button working in baremetal. The explanation is based in the FRDM-KL05Z but it works exactly the same way to the KL25Z.
Best regards,
Earl.
Also, just wanted to add to this post. Learning from this helpful link, I see that the three LEDs (blue, green and red) are all having common anode configuration. This means that (counter-intuitively) all the LED's must be driven high to switch off (using PSOR registers) and driven low to switch on (using PCOR registers).
Hello,
Please take a look into the thread below, specially the post marked as correct answer. It explains how to get a LED and a push button working in baremetal. The explanation is based in the FRDM-KL05Z but it works exactly the same way to the KL25Z.
Best regards,
Earl.
Hi
Probaby the reason why the code doesn't work is because the GPIO is not being enabled/clocked.
Add
SIM_SCGC5 |= SIM_SCGC5_PORTB;
at the start of ledkonf().
[if there is a compilation error check the name of the register/bits in the header that you use and modfiy as required]
Regards
Mark
Kinetis: µTasker Kinetis support
KL25: µTasker Kinetis FRDM-KL25Z support / µTasker Kinetis TWR-KL25Z48M support
For the complete "out-of-the-box" Kinetis experience and faster time to market