Query about reentrancy [.cyre ]file.

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

cross mob
Anonymous
Not applicable

Hi there, I am using the RTC component for the first time and was checking the example project associated with it.

   

This project has a special file alongwith the ".cysch" and ".cydwr" files called ".cyre"

   

I learnt that this is a "reentrancy file" which contains functions names that can be shared by both interrupt and non -interrupt driven codes.

   

 

   

Can someone shed more clear light on this?

   

Regards.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

As long as you observe the rules for reentrancy in your code (do not use global variables, ports or devices) the code generated by GCC is reentrant. I think there is no reentrancy file for PSoC4/5.

   

 

   

Bob

View solution in original post

0 Likes
29 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Take a look at this, also on this page is a link to an ap note

   

on the topic.

   

 

   

http://www.cypress.com/?id=4&rID=38637     www.cypress.com/     AN54460

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Reentracy is a problem for the 8051 core only, since its stack is just 256 bytes in size and local variables cannot be kept there as usual compiler strategy would be. So to keep everything going, the compiler builds a structure form your code to get a look at which function's local variables could be used by another function without destroing any needed information. This leeds to problems with interrupts and when using pointers to functions. The local vars will be allocated on a heap-like structure, but accessing them from the code is more complicated than accessing fixed addresses in sram and so the program will run significantly slower.

   

No similar problems like these on other PSoCs, so when you can spend the money, concentrate on the ARM-core both PSoC5 or 4 offer.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 As bob points out, the re-enetrance issues is mainly for PSoC3 core which is 8051 base. We used that for our projects and use the re-entrance code as it doesn't need to be very fast.

   

It works if you following the instruction but it does slow it down a bit, If you worried about the speed, better use faster PSoC5 which doesn't have the 256 byte stack limitation. Better still is the PSOC3 and PSoC5 are basically PIn to pin compatiable. you can replace a PSOC3 with  PSOC5 with very little or no change to the hardware.

0 Likes
Anonymous
Not applicable
        Okaye.....so does that mean that if I am using PsoC 5, I dont need to make a ".cyre reentrancy file" (& thereby make my functions reentrant) in case of real-time applications like RTC??? Regards.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

As long as you observe the rules for reentrancy in your code (do not use global variables, ports or devices) the code generated by GCC is reentrant. I think there is no reentrancy file for PSoC4/5.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Re-entrancy a problem for M8C as well. From the Compiler manual -

   

 

   

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Which manual did you inspect, the ImageCraft compiler did not mention reentrancy, but I found a hint in the manual for changing from Hi-Tech to ImageCraft. It says

   

   

The HI-TECH

       

   

reentrant keyword enforces the convention of passing parameters through the hardwarereentrant keyword. However, the default ImageCraft functionreentrant convention. This keyword can be removed from

   

Which in my eyes means: ImageCraft inherently generates reentrant code, as long as you follow the required guidelines for reentrancy. Bob (Forum SW is fooling me. I hope this will stay readable)

   

   

stack. ImageCraft does not support the

   

passing convention matches the HI-TECH

   

function declarations.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

What's Tohu's christion name?

   

Bohu! Sorry, but the forum SW mangled my post. Pleas re-arrange the lines for best performance.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given
        From HiTech manual.   
0 Likes
Anonymous
Not applicable
        I think the thread is about PSoC3 not PSoC1.   
0 Likes
Anonymous
Not applicable

Please do not confuse GOOSE. The image craft and hi-tech compiler are for PSoC1 not PSoC3.

0 Likes
Anonymous
Not applicable
        @H L...thanks for your support.....actually its good to corelate between different versions of PSoCs. Regards.   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The discussion includes responses to clarify earlier statements like -


"Reentracy is a problem for the 8051 core only,"


and


" As bob points out, the re-enetrance issues is mainly for PSoC3 core which is 8051 base."


and


"Please do not confuse GOOSE. The image craft and hi-tech compiler are for PSoC1 not PSoC3."



Lets let Goose tell us if he is confused.


In gneral threads are, as y7ou know, multifacted, not constrained to one specifc characteristic.
We have many threads in a specific family discussing other families and their relevance, compari-
son, etc..



Regards, Dana.


PS : I see by Goose's last post he is not confused.
 

0 Likes
Anonymous
Not applicable

 My apologies to incorrectly use thr word ’ONLY’. at that time I was thinking about PSoC3 and PSoC5. My bad.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hey guyz...I am having some problem with the RTC.....to be honest its really small…..I even feeI bad asking it…but I am lost here!!!!!!!!

   

 

   

I tried the RTC example project and it worked properly [I could see the clock moving on the LCD.].

   

Now when I try to duplicate this project..I see the initial values on the LCD ..BUT the clock doesn't move forward.

   

 

   

I simply copied the RTC example project as follows.....

   

------copied the .c code.

   

------added the "utils" header files.

   

------adjusted all the clock settings.

   

------& finally, I also added the ".cyre reentrancy" file.

   

 

   

But still the problem persists.

   

I know I must be missing some minute detail...I've searched all day today and couldn't find any difference with the example project.

   

Here's my project. Are there some more settings required for the RTC?...What am I possibly missing?

   

Regards.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@Goose,

   

Within your main loop "while(1u)" you do not update the display, that's all.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

@BoB........like I said earlier I've simply copied the c code from the RTC example project [which works properly]....so that can't be the problem.

   

Regards.

0 Likes
Anonymous
Not applicable

The RTC example uses PSoC3. And your project is PSOC5 LP.

   

When you said the example works. Were you using PSoC3 or PSoC5?

   

If you used PSoC3 for the examples porject., Had you test your new project with PSoC3?

0 Likes
Anonymous
Not applicable

I am not saying it is the problem, just to collect more information.

0 Likes
Anonymous
Not applicable

Yes Sir, I tested the code on PS0C 3 only...[and like you said, it shouldn't be a problem.]

   

Regards.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You better ought to beleve me!

   

The original program for PSoC3 used the RTC interrupt routine to display all data on the LCD. You stepped into the trap of changing to PSoC5 which generates all modules anew and so not including the alterations made for PSoC3

   

I suggest you to update the clock in the main-loop (and not in the interrupt-routine) which will prevent you from having the same error again when switching to a PSoC4.

   

Have a look into the RTC_INT.c files both in PSoC3 and PSoC3 branch.

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Mis-typed:

   

do not update the clock, but update the display.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

@BoB......I've tried the code on PSoC 3 as well.....still the problem was there!!!

   

Anyways, I'll try to update the display in main() and see what happens!!

   

Regards.

0 Likes
Anonymous
Not applicable

oh...cant believe it...problem solved!!!!!

   

I checked the RTC_INT.c files in both the RTC example project and my test project [which was a copy of example project only].   It turns out both were slightly different.  Even though both the projects were on PSoC 3.

   

Instead of changing my main(), I replaced my RTC_INT.c file with that of the example project and well, it worked.

   

---------------------------------------------

   

I dont get one thing though.......when we update our component pack in PSoC Creator and open an example project, will it not contain the latest version of the component.........I mean how could the generated RTC_INT.c files be different?

   

Regards.

0 Likes
Anonymous
Not applicable

If there are problems with the project, check what are the changes were and re-work with the changes one at a time.

0 Likes
Anonymous
Not applicable

I dont have any problems with the project.......I just wanna ask that :

   

When we take a RTC component in the schematic and build it, its following files are generated...

   

1. RTC.c

   

2. RTC.h

   

3. RTC_INT.c

   

Now if a component has been updated, then the new version will produce some modified files......I agree!!

   

But how come the RTC component in the example project contains a different RTC_INT.c file?

   

In my opinion, if a component is updated, then its example projects should also be modified!!!!

   

Regards.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

In general you are correct, when component is updated so should all

   

appropriate project files. Looks like this one missed. Consider filing

   

a "CASE" so that it gets updated.

   

 

   

"www.cypress.com"
"Support"
"Technical Support"
"Create a Case"

Regards, Dana.

0 Likes
Anonymous
Not applicable

cant believe this was the only problem that was there....i spent an entire day trying to figure out what was wrong with my code!!!

   

Thanks guyz!!

0 Likes