Cpu_Delay100US

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Cpu_Delay100US

4,539 次查看
SofTA
Contributor I
Hi there,
 
It seems the delay of the Cpu_Delay100US() is way off. I am using MC9S08QE128CLK. I want to generate 1 second delay. I used Cpu_Delay100US(10000). But it seems the delay is only about 100mS or so. What am I missing?
 
Thanks in advance.
标签 (1)
标记 (1)
0 项奖励
回复
6 回复数

1,181 次查看
SofTA
Contributor I
Hi Mac,
 
You are right. I strated my project by trying DemoLCD on my evaluation board for learning. Then I copied some DemoLCD code to my board built on PE for getting a quick display. The problem is at ICSSC register. The Cpu_Delay100US code is generated for low bus clock but the DemoLCD code modified ICSSC for high bus clock. After I removed the related DemoLCD code then Cpu_Delay100US worked correctly. I can change the bus clock rate in CPU bean inspector and see the change of the Cpu_Delay100US code generated by PE accordingly. This exercise helpd me understand the MC9S08QE128 CPU and PE a lot. Thank you very much for the help.
0 项奖励
回复

1,181 次查看
SofTA
Contributor I
Hi guys,
 
Thank you for the help. I am new in using CW and MC9S08QE128CLK. Though I can ignore the accuracy of this function and use a number that gives me the delay I need, I think it is imporatant for me to understand why the delay is not right. I have no doubt the delay of the function should be right because it must be used and tested million times by others. So, I just wonder where I have missed so the delay is not right for me (as I described before, it is way off the supposed delay time). Maybe I can look into the problem in another angle: Is there a way (different register settings) to make the delay function runs faster when using ICS? Attached is the main function of my program.
 
Thanks.
 
PS. I tried stepping thru Cpu_Delay100US. It did have received integer 5000 as the delay parameter.
0 项奖励
回复

1,182 次查看
bigmac
Specialist III
Hello,
 
The previously posted file Cpu.c pertained to the HCS08 derivative, whereas the file M1400.c is applicable to the Coldfire derivative.  I wonder if this might be part of the issue?
 
Regards,
Mac
 
0 项奖励
回复

1,182 次查看
SofTA
Contributor I
Hi ProcessorExpert,.
 
I don't have an extern clocking source. I am using the ICS for my design. The Internal bus clock is 4.194304MHz set in Bean Inspector. Attached is the Cpu.c and file. Let me know if you need other files.
 
Thank you for the help
0 项奖励
回复

1,182 次查看
bigmac
Specialist III
Hello,
 
The code for the function Cpu_Delay(), within the posted file, would seem to be quite satisfactory for a bus frequency of 4.194304 MHz.
 
If my calculations are correct, the delay formula works out as 411*(us100)+16 cycles.  For the given clock frequency, the delay formula would be 98*(us100)+4 us, very close to the expected result.
 
For larger values of us100, it would appear that the delay could be even more accurate if the line -
ldhx #$0030 were to be replaced with ldhx #$0031
 
Regards,
Mac
 
0 项奖励
回复

1,182 次查看
ProcessorExpert
Senior Contributor III
The Delay100US() method works correctly and is implemented according to the documentation of Processor Expert.

Delay100US() method realizes software delay, therefore delay realized by this method depends on the bus clock.

If the HW is running with the bus clock different from the value set in the "Internal bus clock" property, then the actual delay can be different from the requested delay. You should verify that the value set in the "Internal bus clock" property corresponds to the real bus clock.

For example if you are using external clock you should verify that the value set in the "Clock frequency [MHz]" property corresponds to the value of the crystal (or oscillator) connected to the CPU on your hardware.

Could you pleas send us your project or settings of the CPU bean to analyse it?

Processor Expert Support Team
www.processorexpert.com
0 项奖励
回复