We are monitoring the cpu usage of our application.
It appear that the access time to peripheral register is over 8 times slower that using RAM memory on the tms570LS2 at 160 Mhz.
That measures affect all peripheral register. GIO, ADC HNET... Is it normal to get that acces time overhead
In the given sample code we got
inHwDeltaCycle = 1022 cycles;
inRamDeltaCycle = 135 cycles;
We compile it using Program Mode compilation (-pm -02 -mf3 ) to force inlining gioSetBit with
==================== resulting assembly =================================
The resulting assembly code if for HET IO
00086e20: EB000F4B BL $../PerformanceMonitor.asm:216:220$
00086e24: E59F6340 LDR R6, $C$CON263
00086e28: E5860000 STR R0, [R6]
00086e2c: E584500C STR R5, [R4, #12] ; DSET
00086e30: E5845010 STR R5, [R4, #16] ; DCLR
.... repeat 48 more time
00086e34: E584500C STR R5, [R4, #12]
00086e38: E5845010 STR R5, [R4, #16]
The resulting assembly code if for pseudo RamIO is
00086e20: EB000F4B BL $../PerformanceMonitor.asm:216:220$
00086e24: E59F6340 LDR R6, $C$CON265
00086e28: E5860000 STR R0, [R6]
00086e2c: E584500C STR R5, [R4, #12] ; DSET
00086e30: E5845010 STR R5, [R4, #16] ; DCLR
.... repeat 48 more time
00086e34: E584500C STR R5, [R4, #12]
00086e38: E5845010 STR R5, [R4, #16]
==================== Source Code =================================
/* USER CODE BEGIN (0) */
// call l argument 50 times;
#define LOOP_50(l) l;l;l;l;l;l;l;l;l;l; \
l;l;l;l;l;l;l;l;l;l; \
l;l;l;l;l;l;l;l;l;l; \
l;l;l;l;l;l;l;l;l;l; \
l;l;l;l;l;l;l;l;l;l;
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
#include "system.h"
#include "PerformanceMonitor.h"
/* USER CODE BEGIN (1) */
#include "het.h"
/* USER CODE END */
/* USER CODE BEGIN (2) */
// ============================== In ram pseudo gioport
gioPORT_t myport
#define ramPORT ((gioPORT_t *)&myport)
// ============================== Performace moditoring result
volatile unsigned int PMU_counter1_result = 0;
volatile unsigned int PMU_counter2_result = 0;
volatile unsigned int PMU_counter3_result = 0;
volatile unsigned int PMU_cycle_count = 0;
unsigned int inRamDeltaCycle = 0;
unsigned int inHwDeltaCycle = 0;
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
void main(void)
{
/* USER CODE BEGIN (3) */
int i;
unsigned value = 0;
/* Enable IRQ */ dsafsd
_enable_IRQ();
/* Set HET port pins to output */
gioSetDirection(hetPORT, 0xFFFFFFFF);
/* Set HET port pin 1 high */
gioSetBit(hetPORT, 1, 1);
/* Send user prompt */
PmInit( PMCC_CYCLE_COUNT, PMCC_CYCLE_COUNT, PMCC_CYCLE_COUNT );
PmClearAndStartCycleCounter();
// ============================== In HW nhet loop
PMU_counter1_result = PmReadCycleCounter();
LOOP_50( gioSetBit(hetPORT, 1, value ^= 1 ))
PMU_counter2_result = PmReadCycleCounter();
// ============================== In RAM pseudo IO loop
LOOP_50(gioSetBit(ramPORT, 1, value ^= 1 ))
PMU_counter3_result = PmReadCycleCounter();
// ============================== Measurement
inHwDeltaCycle = PMU_counter2_result-PMU_counter1_result; // 1022 cycles
inRamDeltaCycle = PMU_counter3_result-PMU_counter2_result; // 135 cycles
asm(" nop");
while(1);
/* USER CODE END */
}