Adsense

How to simulate the basic LED blinking embedded C code on FRDM KL25Z freedom board ?

 // 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

Write a ARM cortex M0+ assembly language code based on arithmatc and logical instructions.

 Problem 1: Implement following code conversions to convert binary no 0x89ABCDEF(32-bits) into a) BCD (64-bits)   b) Gray (32-bits) Problem...