Hi Expert,
My customer run the below code and find take up about 4us, which they think it is too long,
Could you take a check if it make sense to take so long time? thanks.
//************************************************************************************************* // // ESC_readBlockISR // //************************************************************************************************* void ESC_readBlockISR(ESCMEM_ADDR *pData, uint16_t address, uint16_t len) { uint16_t i; // // Create pointer to ESC Address // //const void * escSource = (void *)(ESC_BASE + (uint32_t)(address >> 1U)); uint32_t Addr = ESC_BASE + (uint32_t)(address >> 1U); // // Copy ESC data to buffer. Convert lengths to words. // //memcpy(pData, escSource, (size_t)((len + 1U) >> 1U)); for( i = 0; i< (len >> 1);i++) { pData[ i ] = *(ESCMEM_ADDR*)( Addr + i ); } // // Determine if length (in bytes) is even or odd // (No action on even) // if((len & 0x1U) == 0x1U) { // // Odd Length // // // Clear extra byte in buffer // pData[((len - 1U) >> 1U)] = (pData[((len - 1U) >> 1U)] & ESC_M_LSB); } }
They do a little modification of memory copy function as below and view the assembly code, still take about 4us. any thing wrong ?
ESC_readBlockISR(): 0ab766: B2BD MOVL *SP++, XAR1 174 uint32_t Addr = ESC_BASE + (uint32_t)(address >> 1U); 0ab767: 8F450000 MOVL XAR5, #0x050000 0ab769: 8BA5 MOVL XAR1, @XAR5 0ab76a: FFC0 LSR AL, 1 0ab76b: 80A9 MOVZ AR7, @AL 167 { 0ab76c: 5DA8 MOVZ AR5, @AH 174 uint32_t Addr = ESC_BASE + (uint32_t)(address >> 1U); 0ab76d: B2A9 MOVL @ACC, XAR1 0ab76e: 0DA7 ADDU ACC, @AR7 0ab76f: 8BA9 MOVL XAR1, @ACC 181 for( i = 0; i< (len >> 1);i++) 0ab770: CCA5FFFE AND AL, @AR5, #0xfffe 0ab772: 610C SB $C$L9, EQ 0ab773: 92A5 MOV AL, @AR5 0ab774: D000 MOVB XAR0, #0x0 0ab775: C5A4 MOVL XAR7, @XAR4 0ab776: FFC0 LSR AL, 1 0ab777: 9CFF ADDB AL, #-1 0ab778: 88A9 MOVZ AR6, @AL 183 pData[ i ] = *(ESCMEM_ADDR*)( Addr + i ); $C$L8: 0ab779: 9291 MOV AL, *+XAR1[AR0] 181 for( i = 0; i< (len >> 1);i++) 0ab77a: D801 ADDB XAR0, #1 183 pData[ i ] = *(ESCMEM_ADDR*)( Addr + i ); 0ab77b: 9687 MOV *XAR7++, AL 181 for( i = 0; i< (len >> 1);i++) 0ab77c: 000EFFFD BANZ -3,AR6-- 190 if((len & 0x1U) == 0x1U) $C$L9: 0ab77e: 40A5 TBIT @AR5, #0x0 0ab77f: 6C0A SB $C$L10, NTC 199 pData[((len - 1U) >> 1U)] = (pData[((len - 1U) >> 1U)] & ESC_M_LSB); 0ab780: DD81 SUBB XAR5, #1 0ab781: 92A5 MOV AL, @AR5 0ab782: FFC0 LSR AL, 1 0ab783: 5DA9 MOVZ AR5, @AL 0ab784: A8A9 MOVL @ACC, XAR4 0ab785: 0DA5 ADDU ACC, @AR5 0ab786: 8AA9 MOVL XAR4, @ACC 0ab787: 18C400FF AND *+XAR4[0], #0x00ff $C$L10: 0ab789: 8BBE MOVL XAR1, *--SP 0ab78a: 0006 LRETR