// this is basic LED blinking code realize without external header file of the MKL25Z.h
/* System Integration Module System Clock Gating Control Register 5*/
#define SIM_SCGC5 (*((volatile unsigned int*)0x40048038))
/* Port B Pin Control Register 19*/
#define PORTB_PCR19 (*((volatile unsigned int*)0x4004A04C))
/* Port B Data Direction Register */
#define GPIOB_PDDR (*((volatile unsigned int*)0x400FF054))
/* Port B Data Output Register */
#define GPIOB_PDOR (*((volatile unsigned int*)0x400FF040))
int main (void) {
void delayMs(int n);
SIM_SCGC5 |= 0x400; /* enable clock to Port B */
PORTB_PCR19 = 0x100; /* make PTB19 pin as GPIO (See Table 2-4) */
GPIOB_PDDR |= 0x80000; /* make PTB19 as output pin */
while (1) {
/* turn on green LED */
GPIOB_PDOR &= ~0x80000;
delayMs(1000);
/* turn off green LED */
GPIOB_PDOR |= 0x80000;
delayMs(1000);
}
}
/* Delay n milliseconds
* The CPU core clock is set to MCGFLLCLK at 41.94 MHz in SystemInit().
*/
void delayMs(int n) {
int i;
int j;
for(i = 0 ; i < n; i++)
for (j = 0; j < 7000; j++) {}
}
No comments:
Post a Comment