Adsense

Write embedded C code for KL25Z to transfer data from memory to variable and variable to memory.

Code 1: data transfer from memory to variable and variable to memory of byte size

 #include "MKL25Z4.h"

int main(void)
{
volatile char a = 0x06, c=0x00, d= 0x00;
volatile char *b = &c;
*b= a;                             // variable to memory 8 bit data transfer
d =*b;                             // memory to variable 8 bit data transfer
return 0 ;
}

Result:

Initial value:

After execution of code

 

Code 2: data transfer of half word from memory to variable and variable to memory.

#include "MKL25Z4.h"

int main(void)
{
volatile short int a = 0x06, c=0x00, d= 0x00;
volatile short int  *b = &c;
*b= a;                                // variable to memory 16 bit data transfer
d =*b;                                // memory to variable 16 bit data transfer
return 0 ;
}

Code 3: data transfer of word from memory to variable and variable to memory.

#include "MKL25Z4.h"

int main(void)
{
volatile int a = 0x06, c=0x00, d= 0x00;
volatile int  *b = &c;
*b= a;                                     // variable to memory 32 bit data transfer                           
d =*b;                                     // memory to variable 32 bit data transfer
return 0 ;
}

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