??? 08/27/04 07:23 Read: times |
#76480 - RE: how to do calculations Responding to: ???'s previous message |
hi,
2. also, how do i make calclations on the machine cycles it takes a software to run and it's percentage productivity ? For standard 8051 the one machine cycle takes 12 OSC periods. So if you have 12MHz crystal then one machine cycle is 1μs. Now look at an assembler datasheet and find how many machine cycles each instruction takes. There are instructions which take 1, 2 and 4 machine cycles. Well, knowing all above you may calculate how much machine cycles your refresh routine takes. Then multiple it on 1μs and you get its time now. In fact, a simulator should provide such calculations automaticaly. For example, Keil does calculate time and machine cycles itself during debuging. Okay, let assume you calculated that refresh routine takes 100μs. From other side, to provide 100Hz refresh rate you should refresh all LEDs within 10ms. If you have 7 rows then you should switch refresh task from row to row at each 10ms/7 ~= 1500μs. Now you know that at each 1500μs you should call refresh routine which takes 100μs itself. So find solution of this matrix: 1500μs = 100% (1500-100)μs = x% so x = 1400*100/1500 ~= 93,3% It is productivity of MCU for other tasks. Regards, Oleg |