Hi,
I am running an small applicattion with massive SPI data transfers, and I need to improve the speed of this application. There are only a few lines of code, so I am trying to set the s08Sh at its maximum speed.
I am using the internal clock, and I followed next steps:
- Internal bus clock is set at 16MHz.
- Trim frequency at 39062,50.
Is there something more to do in order to improve the speed of the code?
Thanks.
已解决! 转到解答。
Hi PW_CTL,
You do not need to re-write your code in assembly language. Instead you can look at the assembly language that was generated by your C code (But I don't know the CodeWorrier option to do that). That way, you should be able to optimize your C code to produce the results you need.
What bit-rate do you have the SPI programmed for? What's at the other end?
I have not used the SH family, but the clock module looks similar to the others that I have used. So it looks like you can run the clock in FEI mode (FLL Engaged Internal), program the FLL to get a 40 MHz DCOOUT clock, which would give you a 20 MHz bus clock.
Hi PW_CTL,
There may be a number of things you can do.
First, is there any reason you are not running at 20 MHz instead if 16 MHz? That would be a 25% improvement.
Is your code written in C or assembly language?
Are you running polled or with interrupts?
I'm running older HC08GP32 MCUs at 8 MHz, and I am able to sustain the SPI's maximum transfer rate of 4 MHz (a byte every two microseconds) between MCUs. So I see no reason why you shouldn't be able to do that with an S08 at 16 MHZ.
Hi rocco, thanks for your reply.
I am using processor expert to set up the microcontroller and C code with codewarrior.
As I told you, my application is very small, running in a small loop of only 4-5 lines of c code. I am not using interrupts.
Now, I am reading about 70kbytes/s which is not enough for my purposes. For your comments, there is a problem on my code. I will try to write the main loop in assembly code and check if there is any improvement, but I am not used to write assembly.
About the 20-16MHz, the low-power oscillator can bet set between 2 and 16MHz (my mcu is powered at 3.3V). How to reach the 20MHz? Do I need an external oscillator?
Hi PW_CTL,
You do not need to re-write your code in assembly language. Instead you can look at the assembly language that was generated by your C code (But I don't know the CodeWorrier option to do that). That way, you should be able to optimize your C code to produce the results you need.
What bit-rate do you have the SPI programmed for? What's at the other end?
I have not used the SH family, but the clock module looks similar to the others that I have used. So it looks like you can run the clock in FEI mode (FLL Engaged Internal), program the FLL to get a 40 MHz DCOOUT clock, which would give you a 20 MHz bus clock.
Thanks rocco.
when I was reviewing the code in assembly, I found something wrong on my own code in C. Well, not really wrong but very inefficient, in the way it is translated to assembly. I fixed that and the speed of my applicattion is now about twice than I need!
Thank you very much for your help and advices.