Helpful Information
 
 
Category: Embedded Programming
Question about ARM pipeline hazard

Hi guys,

I have faced an interesting issue in programming the ARM 7 processor. Code was written in assembly to output a pattern on a keil ARM kit. the IDE used was uVision. anyways here is the code:


FIO_BASE_ADDR EQU 0x3FFFC000 ; Initializing addresses of registers
FIO2DIR EQU 0x40
FIO2MASK EQU 0x50
FIO2PIN EQU 0x54
FIO2SET EQU 0x58
FIO2CLR EQU 0x5C

DELAY_COUNT EQU 12000 ; Initializing delay to one second

;----------------------- Pin Connect Block Definitions -------------------------

PCB_BASE EQU 0xE002C000 ; PCB Base Address
PINSEL0_OFS EQU 0x00 ; PINSEL0 Address Offset
PINSEL1_OFS EQU 0x04 ; PINSEL1 Address Offset
PINSEL2_OFS EQU 0x08 ; PINSEL2 Address Offset
PINSEL3_OFS EQU 0x0C ; PINSEL3 Address Offset
PINSEL4_OFS EQU 0x10 ; PINSEL4 Address Offset
PINSEL5_OFS EQU 0x14 ; PINSEL5 Address Offset
PINSEL6_OFS EQU 0x18 ; PINSEL6 Address Offset
PINSEL7_OFS EQU 0x1C ; PINSEL7 Address Offset
PINSEL8_OFS EQU 0x20 ; PINSEL8 Address Offset
PINSEL9_OFS EQU 0x24 ; PINSEL9 Address Offset
PINSEL10_OFS EQU 0x28 ; PINSEL10 Address Offset

; End of initializing addresses of registers
AREA RESET, CODE, READONLY
; Main program
myMain
MOV R0,#0x0 ; R0 = Counter
LDR R4, =DELAY_COUNT

NOP
NOP
;Initializing Port2
MOV R1, #0x0 ;PINSEL10=0x0; ; Disabling the
LDR R2, =PCB_BASE ; ETM interface
STR R1,[R2, PINSEL10_OFS]


The problem is at the line:
LDR R4, =DELAY_COUNT

I have to insert 2 NOPs after it in order for the program to work, otherwise it will freeze and nothing is outputted on the LEDs.

I was thinking it might be a structural hazard in the pipeline, but couldn't figure out exactly why. the instruction after it is a MOV for R1.

Any ideas will be greatly appreciated.

Thanks










privacy (GDPR)