This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I have three questions related to SYS/BIOS Ind. SDK (V1.1.0.4) implementation:
1. Procedure "HW_EscReadByteIsr()" is redirected to "__HW_EscReadByteIsr()" with a #define. The procedure "__HW_EscReadByteIsr()" looks like this:
Uint8 __HW_EscReadByteIsr( Uint16 Address) { Uint8 ByteValue; Int16 sm_index; Uint16 ActAddress = bsp_get_process_data_address(Address, 1, &sm_index); if (ActAddress < ESC_ADDR_MEMORY) { pd_read_addr_err++; return 0; } ByteValue = bsp_read_byte_isr (ActAddress); bsp_process_data_access_complete(Address, 1, sm_index); return ByteValue; }
The same happens to "HW_EscReadWordIsr()". But in "__HW_EscReadWordIsr()" there is a call "bsp_read_word()" instead of "bsp_read_word_isr()" as used in "HW_EscReadByteIsr()".
Is this a bug?
2. Why is "HW_EscReadDWord()" not redirected to "bsp_read_dword()" with a #define, as for example are "HW_EscReadByte()" and "HW_EscReadWord()"? What is the right implementation?
3. Why is there no "__HW_EscReadDWordIsr()" implementation as there is for reading a byte or word?
I'm a bit confused as for me it seems there is no red line in this Read-Procedures.
Thanks and best regards,
Patrick
Hi,
Thanks for the review and feedback. In general, I recommend not using ESC_32BIT_ACCESS and ESC_16BIT_ACCESS for now, as it is not tested. We shall look at enabling this support though in future. As a convention, _isr calls are meant to access process data and normal read/write calls are meant to access ESC registers.
1. Yes - this is a bug. bsp_read_word_isr must be used for __HW_EscReadWordIsr
2. Agree that bsp_read_dword is the ...
3. It really depends on whether you make process data access in 32-bit mode. HW_EscReadWord/ByteIsr is a bit special in this regard as they are meant to touch the first/last word/byte to begin/end process data access. I agree that for completeness sake this is needed...
Following patches may be used as reference to correct above issues...
--- a/ecat_appl/EcatStack/tieschw.h
+++ b/ecat_appl/EcatStack/tieschw.h
@@ -195,13 +195,14 @@ PROTO void HW_EscReadIsr(Uint8 * pData, Uint16 Address, Uint16 Len);
PROTO void HW_EscReadByteIsr(Uint8 ByteValue, Uint16 Address);
PROTO Uint8 __HW_EscReadByteIsr(Uint16 Address);
PROTO Uint16 __HW_EscReadWordIsr(Uint16 Address);
+PROTO Uint32 __HW_EscReadDWordIsr(Uint16 Address);
#define HW_EscReadByteIsr(ByteValue, Address) ((ByteValue) = __HW_EscReadByteIsr(Address))
#define HW_EscReadWordIsr(WordValue, Address) ((WordValue) = __HW_EscReadWordIsr(Address))
+#define HW_EscReadDWordIsr(DWordValue, Address)((DWordValue) = __HW_EscReadDWordIsr(Address))
+
#define HW_EscReadByte(ByteValue, Address) ((ByteValue) = bsp_read_byte(Address))
-//#define HW_EscReadByteIsr(ByteValue, Address) ((ByteValue) = bsp_read_byte_isr(Address))
#define HW_EscReadWord(WordValue, Address) ((WordValue) = bsp_read_word(Address))
-#define HW_EscReadDWord(DWordValue, Address) HW_EscRead(((Uint8 *)&(DWordValue)),((Uint16)(Address)),4)
-#define HW_EscReadDWordIsr(DWordValue, Address) HW_EscReadDWord(DWordValue, Address)
+#define HW_EscReadDWord(DWordValue, Address) ((DWordValue) = bsp_read_dword(Address))
PROTO void HW_EscReadMbxMem(Uint8 * pData, Uint16 Address, Uint16 Len);
--- a/ecat_appl/EcatStack/tieschw.c
+++ b/ecat_appl/EcatStack/tieschw.c
@@ -164,11 +164,29 @@ Uint16 __HW_EscReadWordIsr(Uint16 Address)
pd_read_addr_err++;
return 0;
}
- WordValue = bsp_read_word(ActAddress);
+ WordValue = bsp_read_word_isr (ActAddress);
bsp_process_data_access_complete(Address, 2, sm_index);
return WordValue;
}
+
+Uint32 __HW_EscReadDWordIsr(Uint16 Address)
+{
+ Int16 sm_index;
+ Uint16 ActAddress = bsp_get_process_data_address(Address, 4, &sm_index);
+ Uint32 DWordValue;
+ if (ActAddress < ESC_ADDR_MEMORY)
+ {
+ pd_read_addr_err++;
+ return 0;
+ }
+ DWordValue = bsp_read_dword_isr (ActAddress);
+
+ bsp_process_data_access_complete(Address, 4, sm_index);
+ return DWordValue;
+}
+
void HW_EscReadMbxMem(Uint8 * pData, Uint16 Address, Uint16 Len)
{
t_sm_properties *p_sm_properties = bsp_get_sm_properties(MAILBOX_WRITE);
@@ -218,7 +236,7 @@ void HW_EscWriteWordIsr(Uint16 WordValue, Uint16 Address)
pd_write_addr_err++;
return;
}
- bsp_write_word(WordValue, Address);
+ bsp_write_word(WordValue, ActualAddr);
--- a/ecat_appl/EcatStack/tiescbsp.c
+++ b/ecat_appl/EcatStack/tiescbsp.c
@@ -1695,6 +1719,15 @@ Uint32 bsp_read_dword(Uint16 address)
return DWordValue;
}
+inline Uint32 bsp_read_dword_isr(Uint16 address)
+{
+ Uint32 DWordValue;
+ ENABLE_PRUSS_ACCESS_FROM_HOST();
+ DWordValue = (((Uint32 *) pEsc)[((address) >> 2)]);
+ DISABLE_PRUSS_ACCESS_FROM_HOST();
+ return DWordValue;
+}
+
Hi Pratheesh,
Thanks for the explanations and the patches concerning the Read issues.
Now I still have similar questions for the DWord write functions ("HW_EscWriteDWordIsr()" and "HW_EscWriteDWord()").
For "HW_EscWriteDWordIsr()" I can write a similar function as "HW_EscWriteWordIsr()".
But for "HW_EscWriteDWord()" I have a problem calling the function "bsp_pdi_write_indication()" with a 32bit value.
Any suggestions on this topic?
Thanks and best regards,
Patrick
Hi,
bsp_pdi_write_indication is used by application to indicate write to special ESC registers which firmware needs to handle and value is needed only in the case of write to SM PDI control registers (ESC_ADDR_SMx_PDI_CONTROL). Here you just need to pass LSB of 32-bit word assuming start address is ESC_ADDR_SMx_PDI_CONTROL. This is another reason why we preferred 8-bit processing here...