Adsense

Showing posts with label Data transfer. Show all posts
Showing posts with label Data transfer. Show all posts

write code to transfer block of data from 1FFFF104 to 1FFFF164 and blocksize is stores on 1FFFF100.

;please note here that data transfer done in word only

;first word transfer done between the addresses from 1FFFF1(04 - 05 - 06 - 07) to 1FFFF1(64 - 65 - 66 - 67)

;second word transfer done between the addresses from 1FFFF1(08 - 09 - 0A - 0B) to 1FFFF1(68 - 69 - 6A - 6B)

; and so on

; size of block will be available at location 1FFFF100

;Solution:

 TTL transfer
        AREA Myprog, CODE, READONLY
ENTRY
        EXPORT main
main
            LDR R7,=0x1FFFF100      ;first location initialize to the R7
            LDR R6,=0x1FFFF160    ;second location initialize to R6
            LDR R1,[R7,#0x00]        ;data number need to multiply of 4 as PC+4
            LSLS R1,R1,#0x02        
        ;multiply by 4 if words, 2 if half words and instruction not require in bytes are transferring
            LDR R3,=0x04    ; necessary to shift because PC+4   
Labl1    LDR R2,[R7,R3]    ;first word transfer to R2
            STR R2,[R6,R3]    ;first word store from R2
            ADDS R3,R3,#0x04    ;shift due to word transfer
            SUBS R1,R1,#0x04    ;
            BHI Labl1
done
            SWI &11
            END

Result:

Red colors: data fetch from memory

Green colors: data stored to the memory

Data trasfer instructions of ARM cortex M0/M0+ to memory access through registers.

Memory Accesses register

The Cortex-M0 and Cortex-M0+ processors support a number of memory access instructions, which support various data transfer sizes and addressing modes. The supported data transfer sizes are Word, Half Word, and Byte

Table: Memory access instructions for various transfer sizes

Transfer size Unsigned load     Signed load     Signed/Unsigned store
•Word                 LDR                     LDR                     STR
•Half word         LDRH                  LDRSH               STRH
•Byte                  LDRB                   LDRSB               STRB

Write KL25Z ARM cortex M0+ code to transfer data with in the processor (register to register)

 Assembly code

; Write assembly code to trasfer the data with in the processor
;------------------------------------------------------------------
; Targeted instructions are of mainly four type
; 1. Data transfer Register to Rregister
; 2. data transfer Register to Rregister with all flags get affected
; 3. Immediate data into register with flags get affected
; 4. Special register to register and vice versa
;---------------------------------------------------------------------
        TTL transfer
        AREA Myprog, CODE, READONLY

ENTRY
        EXPORT main
main

        LDR R1,=0x25    ; Load R1 with 0x25
        LDR R2,=0x23    ; Load R2 with 0x23
        MOV R7,R1        ; Mov content of R7 to R1
        MOVS R3,R2        ; Mov content of R2 to R3
        MOVS R4,#0x02    ; Mov immediate 8 bit data 0x22 to R4
        MRS R5,MSP        ; Save specical purpose register APSR's content into R5

        ADDS R5,R5,#0x01; Increse main stack pointer value stored in R5 by 1
        MSR MSP, R5        ; Load content of thr R5 into APSR
done
        SWI &11            ; Call system interrupt to end the program
        END

 Result:


 Embedded C code

#include "MKL25Z4.h"

int main(void)
{
volatile char a = 0x06, c=0x00;
volatile short int    d= 0x00;
c= a;
d = c;
return 0 ;
}

Result:

Data transfer instrutions with in the processor of ARM cortex M0+

 Moving Data within the Processor

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 ;
}

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