From Wikipedia, the free encyclopedia
La FRDM-KL25Z és una plataforma de desenvolupament per a la familia de porcesadors Kinetis L Series KL1x y KL2x basat en el procesador ARM Cortex M0 de 32 bits. Aquesta plataforma és distribuïda per Freescale, i és una gran alternativa a Arduino a causa de la seva senzilla programació i el seu baix cost.
La FRDM-KL25Z té unes grans prestacions per a poder fer projectes d'instrumentació, robotica o pràcticament qualsevol prototip a dissenyar degut a: la seva amplia memòria flash y SRAM, la alta freqüència d'operació, el gran nombre de pins, entre els quals hi ha varis protocolos de comunicació, al acceleròmetre integrat, un LED a disposició, etc.
A més a més, es pot fer servir amb el entorn de programació CodeWarrior de Freescale o amb el compilador en línia MBED que utilitza un sistema fàcil i ràpid amb moltes llibreries per facilitar la programació.
Les característiques de la FRDM-KL25Z són les següents:
El cortex M0 és un microcontrolador RISC amb una arquitectura Von Neumann, és a dir, consta de un sol bus per a les dades i les instruccions. Aquest microcontrolador utilitza un conjunt de instrccions anomenades THUMB el qual esta compost majoritàriament per instruccions de 16 bits, encara que existeixen algunes funcions que utilitzen instruccions de 32 bits. En general, el còrtex M0 té un conjunt de 56 instruccions base, i per això poden tenir més d'una forma.
El ARM Córtex M0+ consta de 2 nivells de pipeline, 16 registres de 32 bits, el NVIC y un multiplicador de 32 bits que varia segons el fabricant. En de la FRDM-KL25Z compta amb un multiplicador de un sol cicle.
El Córtex M0 compta amb el següent:
El Cortex-M0+ es un superset optimitzat del Cortex-M0. El Cortex-M0+ té una compatibilitat de instruccions complerta amb el Cortex-M0 permetent fer servir les mateixes eines de compilació i debugging. El pipeline del Cortex-M0+ té 2 etapes (una menys que el Cortex M0) el que permet un estalvi major de energia. A més a més, existeix una opció silicon que és afegir el Micro Trace Buffer (MTB) que dona una traça simple de instruccions. En el Cortex-M0+ poden ser afegides algunes característiques del Cortex-M3 i Cortex-M4, com per exemple la unitat de protecció de memoria (MPU).
Les característiques claus del Cortex-M0+ són:
Les silicon options són les següents:
El Córtex M0+ conté 16 registres de 32 bits i alguns registres especials:
El processador té 7 modes bàsics d'operació:
Processador | Voltatge d'entrada | Voltatge d'operació | Velocitat CPU | Analògics I/O | PWM | SRAM | Flash | USB | UART | LED | |
---|---|---|---|---|---|---|---|---|---|---|---|
FRDM-KL25Z | ATmega328P | 7-12 V | 5 V | 16 MHZ | 6 inputs / 0 outputs | 6 | 2 KB | 32 KB | Estàndard | 1 | NO |
Arduino UNO | ARM Cortex M0+ | 4.3V - 9V | 1.71V - 3.6V | 48 Mhz | 6 inputs / 0 outputs | 6 | 16 KB | 128 KB | MicroUSB | 3 | SÍ |
A continuació es mostren diferents exemples de codi en les plataformes de Mbed i de CodeWarrior:
#include "mbed.h"
#include "TSISensor.h"
int main(void) {
PwmOut led(LED_GREEN);
TSISensor tsi;
while (true) {
led = 1.0 - tsi.readPercentage();
wait(0.1);
}
}
#include "mbed.h"
#include "MMA8451Q.h"
#define MMA8451_I2C_ADDRESS (0x1d<<1)
int main(void) {
MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
PwmOut rled(LED_RED);
PwmOut gled(LED_GREEN);
PwmOut bled(LED_BLUE);
while (true) {
rled = 1.0 - abs(acc.getAccX());
gled = 1.0 - abs(acc.getAccY());
bled = 1.0 - abs(acc.getAccZ());
wait(0.1);
}
}
#include "mbed.h"
int main() {
DigitalOut rled(LED_RED);
DigitalOut bled(LED_BLUE);
DigitalOut gled(LED_GREEN);
while (1) {
rled = 0;
gled = 1;
bled = 1;
wait(1);
rled = 1;
gled = 0;
bled = 1;
wait(1);
rled = 1;
gled = 1;
bled = 0;
wait(1);
}
}
#include "mbed.h"
Serial pc(USBTX, USBRX);
int main() {
pc.printf("Echoes back to the screen anything you type\n");
while(1) {
pc.putc(pc.getc());
}
}
#include "derivative.h" /* include peripheral declarations */
#define SLOW_BLINK (10000000)
#define FAST_BLINK (1000000)
#define BLINK_DELAY FAST_BLINK
#define RED (18)
#define RED_SHIFT (1 << 18)
#define GREEN (19)
#define GREEN_SHIFT (1 << 19)
#define BLUE (1)
#define BLUE_SHIFT (1 << 1)
#define RED_OFF (GPIOB_PSOR = RED_SHIFT)
#define RED_ON (GPIOB_PCOR = RED_SHIFT)
#define RED_TOGGLE (GPIOB_PTOR = RED_SHIFT)
#define GREEN_OFF (GPIOB_PSOR = GREEN_SHIFT)
#define GREEN_ON (GPIOB_PCOR = GREEN_SHIFT)
#define GREEN_TOGGLE (GPIOB_PTOR = GREEN_SHIFT)
#define BLUE_OFF (GPIOD_PSOR = BLUE_SHIFT)
#define BLUE_ON (GPIOD_PCOR = BLUE_SHIFT)
#define BLUE_TOGGLE (GPIOD_PTOR = BLUE_SHIFT)
void delay_time(int);
void init_leds();
void red_on();
void red_off();
void green_on();
void green_off();
void blue_on();
void blue_off();
/********************************************************************/
int main (void)
{
int i=0;
init_leds();
while(1)
{
i++; /* just a count variable. */
red_on();
delay_time(BLINK_DELAY); /* Red */
red_off();
green_on();
delay_time(BLINK_DELAY); /* Green */
green_off();
blue_on();
delay_time(BLINK_DELAY); /* Blue */
red_on();
delay_time(BLINK_DELAY); /* Blue + Red */
green_on();
blue_on();
delay_time(BLINK_DELAY); /* Red + Green */
red_off();
blue_on();
delay_time(BLINK_DELAY); /* Green + Blue */
red_on();
delay_time(BLINK_DELAY); /* Green + Blue + Red */
green_off();
blue_off();
}
}
void red_on(){
RED_ON;
}
void red_off(){
RED_OFF;
}
void green_on(){
GREEN_ON;
}
void green_off(){
GREEN_OFF;
}
void blue_on(){
BLUE_ON;
}
void blue_off(){
BLUE_OFF;
}
/********************************************************************/
void delay_time(int number){
int cnt;
for(cnt=0;cnt<number;cnt++);
}
/********************************************************************/
/********************************************************************/
/* init_leds()
* initialize the ports for LEDs
* ******************************************************************/
void init_leds()
{
/*
* Initialize the Red LED (PTB18)
*/
/* Turn on clock to PortB module */
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
/* Set the PTB18 pin multiplexer to GPIO mode */
PORTB_PCR18 = PORT_PCR_MUX(1);
/* Set the initial output state to high */
GPIOB_PSOR |= RED_SHIFT;
/* Set the pins direction to output */
GPIOB_PDDR |= RED_SHIFT;
/*
* Initialize the Green LED (PTB19)
*/
/* Turn on clock to PortB module */
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
/* Set the PTB19 pin multiplexer to GPIO mode */
PORTB_PCR19 = PORT_PCR_MUX(1);
/* Set the initial output state to high */
GPIOB_PSOR |= GREEN_SHIFT;
/* Set the pins direction to output */
GPIOB_PDDR |= GREEN_SHIFT;
/*
* Initialize the Blue LED (PTD1)
*/
/* Turn on clock to PortB module */
SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;
/* Set the PTD1 pin multiplexer to GPIO mode */
PORTD_PCR1 = PORT_PCR_MUX(1);
/* Set the initial output state to high */
GPIOD_PSOR = BLUE_SHIFT;
/* Set the pins direction to output */
GPIOD_PDDR |= BLUE_SHIFT;
}
#include "MKL25Z4.h"
#include <math.h>
int main()
{
int count = -250;
MCG_BASE_PTR->C1 = MCG_C1_IREFS_MASK | MCG_C1_IRCLKEN_MASK; // INTERNAL CLOCK|MCGIRCLK ACTIVE(SET)
MCG_BASE_PTR->C2 = MCG_C2_IRCS_MASK; // SELECT FAST INTERNAL REFERENCE CLOCK (1)
SIM_BASE_PTR->SCGC6 |= SIM_SCGC6_TPM2_MASK; // ENABLE TPM2 CLOCK GATE
SIM_BASE_PTR->SOPT2 |= SIM_SOPT2_TPMSRC(3); // MCGIRCLK IS SELECTED FOR TPM CLOCK
TPM2_BASE_PTR->SC |= TPM_SC_PS(2); // --preescaler
TPM2_BASE_PTR->SC |= TPM_SC_CMOD(1); // COUNTER INC. ON EVERY CLOCK
TPM2_BASE_PTR->MOD = 10000; // Frecuency
SIM_BASE_PTR->SCGC5 |= SIM_SCGC5_PORTB_MASK;
PORTB_BASE_PTR->PCR[2] = PORT_PCR_MUX(3); Mux mode
TPM2_BASE_PTR->CONTROLS[0].CnSC = TPM_CnSC_MSB_MASK | TPM_CnSC_ELSB_MASK; // SELECT CHANNEL MODE
//TPM2_BASE_PTR->CONTROLS[0].CnV = 750;
while(1){
if(TPM2_BASE_PTR->CONTROLS[0].CnV == 1250 || TPM2_BASE_PTR->CONTROLS[0].CnV == 750){
count = -count;
}
TPM2_BASE_PTR->CONTROLS[0].CnV +=count;
}
return 0;
}
[1] Exemple LED
[2] Exemple ADC
[3] Exemple DAC
[4] Repositori de còdi
[5] NXP Oficial web
[6] FRDM-KL25Z Development-tools
[7] Mbed Developer
[8] Mbed Platforms
[9] Mbed SerialPC
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.