Adsense

Write Embedded C code to blink green LED with MKL25Z4.h library on KL25Z FRDM board.

 /* Toggling green LED on FRDM-KL25Z board with MKL25Z library
 * Program toggles green LED on the FRDM-KL25Z board.
 * The green LED is connected to PTB19.
 * The LEDs are low active (a '0' turns ON the LED).
 */

#include <MKL25Z4.H>

int main (void) {
    void delayMs(int n);
        
        // setup part includes Enable of clock, configure GPIO and output
    
    SIM->SCGC5 |= 0x400;        /* enable clock to Port B */
    PORTB->PCR[19] = 0x100;     /* make PTB19 pin as GPIO */
    PTB->PDDR |= 0x80000;       /* make PTB19 as output pin */
    
        // always run loop
    while (1) {
        PTB->PDOR &= ~0x80000;  /* turn on green LED */
                delayMs (20000);
                PTB->PDOR |= 0x80000;  /* turn off green LED */
                delayMs (20000);
    }
}

/* 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 < 16000; 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...