Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC code improvement

Status
Not open for further replies.

dmta

Member level 2
Member level 2
Joined
Mar 25, 2013
Messages
52
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Earth
Visit site
Activity points
1,650
Dear all,

I have this program where inside a timer interrupt I need to carry out certain things. One of this is to execute the following line of code. But when I do this the microcontroller takes some time to compute the value. Can you give me any suggestions to improve it? the variables are in type int

HTML:
 z_n = xor + ((z_n*63)>>6);
          xor_sum = z_n>>6;

Best regards
 

cannot see any obvious way to improve performance - clearly the * is the longest operation - can you give more details of the algorithm?
how often does the timer interrupt? if only mSeconds there should be no problem but get 50000 interrupts/second and you could have timing problems
can you increase the processor clock by using clock multipliers which are available on the more powerful PICs?
 

Dear all,

I have this program where inside a timer interrupt I need to carry out certain things. One of this is to execute the following line of code. But when I do this the microcontroller takes some time to compute the value. Can you give me any suggestions to improve it? the variables are in type int

HTML:
 z_n = xor + ((z_n*63)>>6);
          xor_sum = z_n>>6;

Best regards

I would try to convert

z_n*63 -> ((z_n << 6) - z_n) // = z_n * 64 - z_n = z_n*(64-1)




Re writing


HTML:
 z_n = xor + (((z_n << 6) - z_n)>>6);
          xor_sum = z_n>>6;


Hope it helps.

Simao
 
  • Like
Reactions: dmta

    dmta

    Points: 2
    Helpful Answer Positive Rating
very sorry for this late reply... the answer is correct. !!!!!!!!!!!!!!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top