Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

DAVE™ Forum Discussions

Not applicable
Hi,

I am working with xmc4500 relax kit and having a problems with POSIF interrupts. I want to track the positions so i am using POSQE001 App. I want to have two interrupts at position counter compare match and position counter period match. These two interrupts are mapped to my own functions with two NVIC002 apps. I am only able to get period match interrupt only in one direction. Compare match interrupt does not occur no matter what i do. Also in order to get period match interrupt, i have to check the option in POSQE001 App GUI setting panel (Enable Position counter overflow event) in addition to manually enabling the event in main function with the following code. if i do not check it this, then period match interrupt also does not occur.

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,POSQE001_POSITION_COUNTER,POSQE001_CCU_PERIOD_MATCH);


I dont know why i need to enable the GUI option, when i am enabling the events manually. but the problem does not end here this period match interrupt only occurs in one direction of movement but not in the other direction e.g it occurs only in Clockwise direction, but not in anti- clockwise direction. it should occur in both directions.

could anyone please explain what the option in POSQE001 App GUI setting panel (enable Position counter overflow event) means, what does it do, why is it necessary. and is it necessary to check if i am enabling the events manually. because if i do not check it and enable the events manually then both interrupts does not work.

secondly and most Importantly, please someone help me how to get compare match interrupt and period match interrupt working in both directions. I am also enabling the events manually and setting CompareMatch and PeriodMatch values with the following code in main function, but nothing is helping.


int main(void)
{
status_t Status;

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_PERIOD_MATCH);

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_UP_COMPARE_MATCH);

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_DOWN_COMPARE_MATCH);

Status = POSQE001_Start(&POSQE001_Handle0);

Status = POSQE001_SetPeriodCounterPM(&POSQE001_Handle0, 80);

Status = POSQE001_SetPeriodCounterCM(&POSQE001_Handle0, 40);
}


and also one more question when does Position counter Event 0,1 and 2 interrupts occur? what are Position counter Event 0,1 and 2?
0 Likes
7 Replies
Not applicable
Hi,

I think the issue is regarding signal connection and enabling the correct events in clockwise and anti-clockwise direction.
Please find detailed explanation below:

Explanation about the events used in APP:
Position counter Event 0: External count mode (quadrature clock of POSIF is connected to CCU4 slice event 0)
Position counter Event 1: External direction (direction signal of POSIF connected to CCU4 slice event 1)
Position counter Event 2: not used

GUI option to enable position counter overflow:
GUI option enables the CCU4 period match event in the code. It is same as enabling event manually in main code.

Interrupts:
signal connection with NVIC002 APP is required which assigns the correct SR number to particular event. I think user is not doing this signal connection (period match event to NVIC002/0 and compare match event to NVIC002/1).
In anti-clockwise direction, user will get one match event instead of one match event.
This can be enabled manually as
POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,
POSQE001_POSITION_COUNTER,
1U);

Regarding compare match, he has already enabled both up and down compare match. I believe if signal connection is correct, he should get this interrupt.


Also, one more change in the code - Configure compare match and period match before starting the application.

int main(void)
{
status_t Status;

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_PERIOD_MATCH);

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,
POSQE001_POSITION_COUNTER,
1U); //one-match event
Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_UP_COMPARE_MATCH);

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_DOWN_COMPARE_MATCH);
Status = POSQE001_SetPeriodCounterPM(&POSQE001_Handle0, 80);

Status = POSQE001_SetPeriodCounterCM(&POSQE001_Handle0, 40);

Status = POSQE001_Start(&POSQE001_Handle0);

}
0 Likes
Not applicable
hi

thanks for a quick replay. but i am already doing signal connection and did not mention in my question the first time. i am sending you screenshots. i am using NVIC002 APP in other peripheral interrupts too e.g in usart, there its not a probelm and it works fine. secondly, before posting the question here, i have already tried setting the period match and compare match before starting the app too. it also did not work please find the pictures of the connection signals below.
1497.attach
1498.attach

also about the GUI option if i try to uncheck it and then enable event manually then no interrupt occur although as you mention they both are the same. dont know whats happening.:rolleyes:

and one more question does one match also trigger period match interrupt because in signal connection drop down there is no one match interrupt option to write ISR.

please help.
0 Likes
Not applicable
Hi,

GOOD NEWS is that the problem has been identified and solved 🙂 .I think there is a bug or you could say there is a weird implementation in the POSQE001 App. now here is the problem. when you write the following code
Status = POSQE001_Start(&POSQE001_Handle0);

It initializes the position interface with the user selected options in GUI. If you do not select GUI option to enable position counter overflow then code generated for the INTE register for CCU4 slice has a value which corresponds to no interrupt enable. that is 0x0. if it is selected then only Period Match interrupt enable with INTE value 0x01.

now if you change the value of INTE register of CCU4 slice with the function.
Status = POSQE001_EnableEvent((POSQE001_HandleType*),POSQE001_SLICE,POSQE001_EVENT);


and then you start the app with the code
Status = POSQE001_Start(&POSQE001_Handle0);

It overrides the changes made before calling the POSQE001_Start() function. that is why i was only getting one period match interrupt when i checked the GUI option and no interrupt when i unchecked the GUI option.

so the workaround is obvious that first call the start POSIF app function then enable the required events.:cool:

BUT

I would suggest to change the behavior of the app in future versions that it ORs the user selected option(0x01/0x00) with INTE register value instead of completely overriding it or mention in the documentation or comments of the code to the user that call EnableEvent() function after starting the app. that would help alot of users and prevent alot of pain.

now the question that remains unanswered to me is when one match event occurs the same Period match ISR is called or separate one match ISR has to be written, if separate ISR has to be written then there is no option in POSIF app for position counter OneMatch interrupt to connect it to NVIC002 app to write an ISR.

Could any one now explain this last confusion. 🙂
0 Likes
Not applicable
Hi,

GOOD NEWS is that the problem has been identified and solved 🙂 .I think there is a bug or you could say there is a weird implementation in the POSQE001 App. now here is the problem. when you write the following code
Status = POSQE001_Start(&POSQE001_Handle0);

It initializes the position interface with the user selected options in GUI. If you do not select GUI option to enable position counter overflow then code generated for the INTE register for CCU4 slice has a value which corresponds to no interrupt enable. that is 0x0. if it is selected then only Period Match interrupt enable with INTE value 0x01.

now if you change the value of INTE register of CCU4 slice with the function.
Status = POSQE001_EnableEvent((POSQE001_HandleType*),POSQE001_SLICE,POSQE001_EVENT);


and then you start the app with the code
Status = POSQE001_Start(&POSQE001_Handle0);

It overrides the changes made before calling the POSQE001_Start() function. that is why i was only getting one period match interrupt when i checked the GUI option and no interrupt when i unchecked the GUI option.

so the workaround is obvious that first call the start POSIF app function then enable the required events.:cool:

BUT

I would suggest to change the behavior of the app in future versions that it ORs the user selected option(0x01/0x00) with INTE register value instead of completely overriding it or mention in the documentation or comments of the code to the user that call EnableEvent() function after starting the app. that would help alot of users.

now the question that remains unanswered to me is when one match event occurs the same Period match ISR is called or separate one match ISR has to be written, if separate ISR has to be written then there is no option in POSIF app for position counter OneMatch interrupt to connect its NVIC002 app to write an ISR.

Could any one explain this last thing to me please 🙂
0 Likes
Not applicable
Hi,

I don't quite understand your question. Can you please elaborate.

Normally, the APP is designed to fulfil a certain use case condition in mind as in the documentation. Of course it is possible for the user to customised the code to their application, however, this must be done with understanding. Here's the user can choose to retain the APP settings or override the conditions and this is beyond the control of the APP.

On your question on one match and period match:
One match is only available when the CCUx is operating in center aligned mode. When the timer is counting up and reaches the value in the PR register, a period match event occurs. When the timer is counting down and reaches 0001, at the next cycle a one match event occurs. As a user, you can enable the events to be connected to the available interrupt nodes (same or different nodes) depending on your application.

Regards,
Daryl 🙂
0 Likes
Not applicable
Hi,

Thanks for your reply. yes, you are right that the user can retain app settings or override and it should be beyond the control of the app, but only, if the app is working properly. but in this case it is not what is happening 😉 the app is overriding the user settings if the start() is called after changes made by the user. you can test it yourself by your own code. which you suggested in your first reply. which is as follows.

int main(void)
{
status_t Status;

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE0 01_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_PERIOD_MATCH);

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE0 01_Handle0,
POSQE001_POSITION_COUNTER,
1U); //one-match event
Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE0 01_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_UP_COMPARE_MATCH);

Status = POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE0 01_Handle0,
POSQE001_POSITION_COUNTER,
POSQE001_CCU_DOWN_COMPARE_MATCH);
Status = POSQE001_SetPeriodCounterPM(&POSQE001_Handle0, 80);

Status = POSQE001_SetPeriodCounterCM(&POSQE001_Handle0, 40);

Status = POSQE001_Start(&POSQE001_Handle0);

int i=0;// add this line for break point.
}

Put a break point at int i=0 line and run the code then in debugging mode check the value of INTE register of CCU4 slice responsible for Position counter. With these settings made by Enable event(), the value should be 0x10f, but it would be either 0x00 if GUI option is not selected or 0x01 if GUI option is selected.:o

then next time repeat the process by making small change in the code "Status = POSQE001_Start(&POSQE001_Handle0);" put this line at the top after "status_t Status;" line and then in debugging see the value of the INTE register it would be as expected.

of course i changed the code accordingly to work properly for my purposes.:cool:

I hope this helps.

Regarding the second question you are right too in general case, i can call same ISR or different ISR on one compare event. but for that settings a signal connection to NVIC002 app should be made, there is no option in POSQE app, see the pic below.

1502.attach

in signal drop down there is no option to make connection for position counter one compare event. In POSQE app the default is center aligned counter mode so this option should be there.

But, with the hit and trial method i found that in one compare match event, the period match ISR is called. but i dont know how to call a separate ISR for one compare in POSQE app. when there is no option to make a connection to NVIC002 app. that is my question, i hope this explanation helps.

Best Regards 🙂
0 Likes
Not applicable
Hi,

You are right, the APP should not override user's setting.
In the routine "Status = POSQE001_Start(&POSQE001_Handle0);" , an API to program the INTE was called.

/*
* Program the Slice Interrupt register
*/
CCU4SliceRegPtr->INTE = SliceConfigPtr->InterruptMask; // Bug//Here the INTE overrides the user's settings

For this, I have filed the following e-Ticket ( Reference #252917541)

Regarding signal connection, one match event signal and period match event signal are using the same signal. Similarly, compare up match and compare down match signals are same signal.
You can get the control in the same ISR depending upon the direction of counting. The only thing that needs to done is to enable the event (one match and compare down) in INTE register.

Regards,
Daryl
0 Likes