Jun 10, 2013
07:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2013
07:13 AM
4 Replies
Jun 10, 2013
09:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2013
09:57 AM
Hi OMR,
please have a look to the following code. It should do its job, although I did not test it. Could you please check and give feedback? Thanks a lot.
Best Regards,
Arno
please have a look to the following code. It should do its job, although I did not test it. Could you please check and give feedback? Thanks a lot.
Best Regards,
Arno
status_t POSQE001_SetPosition
(
const POSQE001_HandleType* HandlePtr,
uint16_t* Position,
POSQE001_ReadRegType ReadMethod
)
{
uint32_t* PosTimerRegPtr = (uint32_t*) HandlePtr->PosCounterRegPtr[1];
status_t Status = (uint32_t)POSQE001_OPER_NOT_ALLOWED_ERROR;
DBG002_FUNCTION_ENTRY(DBG002_GID_POSQE001, POSQE001_FUNCTION_ENTRY);
if(HandlePtr->DynamicHandlePtr->AppState == POSQE001_UNINITIALIZED)
{
DBG002_ERROR(DBG002_GID_POSQE001, (uint8_t)Status, 0, (uint8_t*) NULL);
}
else
{
*PosTimerRegPtr = *Position;
Status =(uint32_t) DAVEApp_SUCCESS;
}
DBG002_FUNCTION_EXIT(DBG002_GID_POSQE001, POSQE001_FUNCTION_EXIT);
return (Status);
}
Jun 11, 2013
01:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 11, 2013
01:44 AM
Thank you for your answer Arno.
We have tried the code, but the writing to *PosTimerRegPtr seems to have no effect.
The address of the pointer is 0x4000c270, we try to write the value of position (160) into *0x4000c270, but its value does not change (4351)
Found this:
Field Bits Type Description
TVAL [15:0] rwh Timer Value
This field contains the actual value of the timer.
A write access is only possible when the timer is
stopped.
0 [31:16] r Reserved
A read access always returns 0
Might need to figure out how to stop the timer prior to writing, and then start it again.
Tried this, did not work:
POSQE001_Stop(HandlePtr);
*PosTimerRegPtr = position;
POSQE001_Start(HandlePtr);
Tested some more:
uint32_t *TCSET = (uint32_t *)0x4000c20c;
uint32_t *TCCLR = (uint32_t *)0x4000c210;
uint32_t *TCST = (uint32_t *)0x4000c208;
*TCCLR = 1;
*PosTimerRegPtr = position;
*TCSET = 1; // setting this, clears/reloads the timer, so that value written is lost.
If I don't do the *TCSET=1; the SW reads the correct angle, but the counter is of course stuck.
Is there a way to prevent the reload after starting the timer again?
I have tested by single stepping in the debugger.
Another issue arises when running at full speed:
http://www.infineonforums.com/threads/410-Can-t-update-CCU4-timer-without-adding-nops-between-start-...
We have tried the code, but the writing to *PosTimerRegPtr seems to have no effect.
The address of the pointer is 0x4000c270, we try to write the value of position (160) into *0x4000c270, but its value does not change (4351)
Found this:
Field Bits Type Description
TVAL [15:0] rwh Timer Value
This field contains the actual value of the timer.
A write access is only possible when the timer is
stopped.
0 [31:16] r Reserved
A read access always returns 0
Might need to figure out how to stop the timer prior to writing, and then start it again.
Tried this, did not work:
POSQE001_Stop(HandlePtr);
*PosTimerRegPtr = position;
POSQE001_Start(HandlePtr);
Tested some more:
uint32_t *TCSET = (uint32_t *)0x4000c20c;
uint32_t *TCCLR = (uint32_t *)0x4000c210;
uint32_t *TCST = (uint32_t *)0x4000c208;
*TCCLR = 1;
*PosTimerRegPtr = position;
*TCSET = 1; // setting this, clears/reloads the timer, so that value written is lost.
If I don't do the *TCSET=1; the SW reads the correct angle, but the counter is of course stuck.
Is there a way to prevent the reload after starting the timer again?
I have tested by single stepping in the debugger.
Another issue arises when running at full speed:
http://www.infineonforums.com/threads/410-Can-t-update-CCU4-timer-without-adding-nops-between-start-...
Jun 11, 2013
07:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 11, 2013
07:51 AM
Now it is working 🙂
The way to avoid reload when restarting the timer was to reset the TC.STRM and TC.ENDM bits.
The 'quick & dirty' code then looks like this: (maybe you can clean it up Arno?)
uint32_t position;
uint32_t* PosTimerRegPtr = (uint32_t*) posQeHandle_->PosCounterRegPtr[1];
uint32_t *TCSET = (uint32_t *)0x4000c20c;
uint32_t *TCCLR = (uint32_t *)0x4000c210;
uint32_t *TCTC = (uint32_t *)0x4000c214;
*TCCLR = 1; // stop the timer
__DSB(); // flush pipeline
*PosTimerRegPtr = position; // write to TIMER register
*TCTC = 0x1000; // reset extended start/stop control bits
*TCSET = 1; // start timer again
The way to avoid reload when restarting the timer was to reset the TC.STRM and TC.ENDM bits.
The 'quick & dirty' code then looks like this: (maybe you can clean it up Arno?)
uint32_t position;
uint32_t* PosTimerRegPtr = (uint32_t*) posQeHandle_->PosCounterRegPtr[1];
uint32_t *TCSET = (uint32_t *)0x4000c20c;
uint32_t *TCCLR = (uint32_t *)0x4000c210;
uint32_t *TCTC = (uint32_t *)0x4000c214;
*TCCLR = 1; // stop the timer
__DSB(); // flush pipeline
*PosTimerRegPtr = position; // write to TIMER register
*TCTC = 0x1000; // reset extended start/stop control bits
*TCSET = 1; // start timer again
Jun 21, 2013
04:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 21, 2013
04:43 AM
Well, since Arno was not in a hurry, here we go:
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->TCCLR = 1;
__DSB();
*PosTimerRegPtr = position;
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->TC = 0x1000;
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->TCSET = 1;
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->TCCLR = 1;
__DSB();
*PosTimerRegPtr = position;
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->TC = 0x1000;
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->TCSET = 1;