Hi jeremyzhou,
I have found a code for Cortex M3/M4 to get the instruction cycle count. The code I used is:
volatile unsigned int *DWT_CYCCNT ;
volatile unsigned int *DWT_CONTROL ;
volatile unsigned int *SCB_DEMCR ;
void reset_timer(void)
{
DWT_CYCCNT = (unsigned int *)0xE0001004;
DWT_CONTROL = (unsigned int *)0xE0001000;
SCB_DEMCR = (unsigned int *)0xE000EDFC;
*SCB_DEMCR = *SCB_DEMCR | 0x01000000;
*DWT_CYCCNT = 0;
*DWT_CONTROL = 0;
}
void start_timer(){
*DWT_CONTROL = *DWT_CONTROL | 1 ;
}
void stop_timer(){
*DWT_CONTROL = *DWT_CONTROL | 0 ;
}
unsigned int getCycles(){
return *DWT_CYCCNT;
}
Inside main():-
reset_timer();
start_timer();
asm("nop");
stop_timer();
DEBUGOUT("Cycles: %d\r\n", getCycles());
I am using 24 MHz oscillator configured to 72 MHz CPU clock, EMC clock, & Peripheral clock. Please try this and acknowledge.
I also came across a strange thing, when I have used 12 MHz crystal(not oscillator) instead of 24 MHz crystal that I was using, the instruction cycles in user app came down to almost 1/3rd of the previous with same frequency configuration. I don't understand this, though LPC4088 UM does recommend 12 MHz crystal.
A few more doubts which I read in ARM PrimeCell MultiPort Memory Controller documents:
- If the memory bus is multiplexed externally, for example by using an EBI, the worst-case transfer latency is affected because the external bus is shared by multiple devices.
- AHB port 0 is the highest priority port, AHB port 3 is the lowest priority port.
- Lower priority AHB memory ports can be locked out indefinitely if a higher priority AHB memory port continually performs memory requests.
- The memory controller AHB memory ports are prioritized. If a master connected to a HIGH priority port performs continuous transactions, lower priority ports are not able to access the bus until the higher priority port has completed its transactions.
Now I have connected FPGA to CS0, SRAM to CS1, & Nor Flash to CS3. Can you help me explain above statements in reference to my hardware connections. After reading this I was planning to swap FPGA & Nor-Flash & see what happens.
Regards
Priyank.