Part Number: TMS320F28377D
I have a question regarding data cache behavior when copying data from flash memory to RAM.
**Environment:**
- CPU: TMS320F28377D
- Board: Custom PCB
- Clock frequency: 200MHz (5ns/cycle)
- Code section: .TI.ramfunc (executed from RAM)
- Flash wait states: 3 cycles
- Data cache: Enabled
- Prefetch: Enabled
**Test Performed:**
I measured the processing time by toggling GPIO13 while copying 128 bits of data from flash memory (Sector H: 0x0a1700) to RAM (LS5: 0x00ac00) using two different methods:
1. PREAD instruction: Reading 16-bit data 8 times
2. MOVL instruction: Reading 32-bit data 4 times
**Measurement Results:**
- PREAD: 170ns
- MOVL: 70ns
- Results were identical when reversing the execution order
**Test Code:**
MOVW DP,#_GpioDataRegs
; copy flash to RAM ( word * 8 )
MOVL XAR7,#0x0a1700 ; Source (Flash Sector H)
MOVL XAR4,#0x00ac00 ; Destination (LS5 RAM)
OR @_GpioDataRegs+2,#0x2000 ; GPIO13=High
RPT #7
|| PREAD *XAR4++,*XAR7
OR @_GpioDataRegs+4,#0x2000 ; GPIO13=Low
NOP
; copy flash to RAM ( double word * 4 )
MOVL XAR7,#0x0a1700 ; Source (Flash Sector H)
MOVL XAR4,#0x00ac00 ; Destination (LS5 RAM)
OR @_GpioDataRegs+2,#0x2000 ; GPIO13=High
L1: MOVL ACC, *XAR7++
MOVL *XAR4++, ACC
L2: MOVL ACC, *XAR7++
MOVL *XAR4++, ACC
L3: MOVL ACC, *XAR7++
MOVL *XAR4++, ACC
L4: MOVL ACC, *XAR7++
MOVL *XAR4++, ACC
OR @_GpioDataRegs+4,#0x2000 ; GPIO13=Low
**My Hypothesis:**
For MOVL instruction: The first read incurs wait cycles (3 cycles) for a total of 4 cycles, while subsequent reads hit the cache and take only 1 cycle each. Total: 5ns × (4+7) = 55ns
For PREAD instruction: The cache is not utilized, and wait cycles occur for every read. Total: 5ns × 4 × 8 = 160ns
**Questions:**
1. Is this hypothesis correct?
2. Why doesn't the PREAD instruction utilize the cache, even though both data cache and prefetch are enabled?
3. Is there any possibility that I'm misconfiguring something or using these instructions incorrectly?
Any insights would be greatly appreciated.
Thank you in advance for your help.