Hello,
I am working with a MC9S08QG8 and Codewarrior V11 and I am using the SCI component (among others) so that I can have serial communication with the embedded hosting board from a custom software tried before.
When debugging, the communication works fine, but after I "Flash File to Target", thinking in production, the baudrate of the micro controller changes from 19230.769 to 21000 baud aproximattely.
I think that the timer is also afected, so I can deduce that the internal clock frequency is changing...
I have tried to program the micro controller with the .abs, .abs.args, .abs.s19 but with all of them the result is the same.
So, any idea of what can be goin on and how to fix it?
Thank you in advance.
已解决! 转到解答。
Thank you for your answer Vicente.
I asked also support to PEmicro, and according to what they say, when debugging, in my case with a Multilink, it's PEmicro's implementation and trimming works fine, but the "Flash File to Target" option is Codewarrior's implementation and this functionallity may not be implemented eventhough the option appears as well.
By the way, it seems that the Cyclone programmer has also the functionallity, so, in that case, the issue would be resolved. Soon I will have the oportunity to try it, so I will let you know.
Regards.
Hello,
If you use the internal oscillator, if you want accurate frequency, you have to use the trim register (ICSTRM see data-sheet chapter 10 ), and look at options to your programming tool, you probably found something about that.
Regards,
Emmanuel
Hello Emmanuel,
Thank you for your answer, it's been very useful!
With your hint, I realized that the processor expert does not initialize the trim value registers.
It seems that when debugging, the values are inserted anyway, but not when flashing, so I introduce the needed values by "hand" and it works properly.
I wonder why the PE doesn't generate that code if it give you the option to select it...
Anyway, thank you again.
Hello again,
I just realized that this is not the solution...every time I debug a diferent micro, I can see that the values of those registers (ICSTRM and ICSSC) change for each.
I don't know where and how the values of those registers are calculated and inserted, because they already appear before start running the code...
When flashing, those registers have 0x80 and 0x00 values by default.
So, how can those values be inserted automatically without debugging?
Hi
Please add the following lines on the star08.c file
/* System clock initialization */
/*lint -save -e923 Disable MISRA rule (11.3) checking. */
if (*(uint8_t*)0xFFAFU != 0xFFU) { /* Test if the device trim value is stored on the specified address */
ICSTRM = *(uint8_t*)0xFFAFU; /* Initialize ICSTRM register from a non volatile memory */
ICSSC = *(uint8_t*)0xFFAEU; /* Initialize ICSSC register from a non volatile memory */
}
/*lint -restore Enable MISRA rule (11.3) checking. */
/* ICSC1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=0,IREFSTEN=0 */
setReg8(ICSC1, 0x04U); /* Initialization of the ICS control register 1 */
/* ICSC2: BDIV=1,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0 */
setReg8(ICSC2, 0x40U); /* Initialization of the ICS control register 2 */
I hope this will help you
have a good day.
Hello Vicente,
I really appreciate your answer, but I have already tried that as PE generates the code.
In this case happens the same, by the time I connect for debug, without running yet, the selected memory locations already have the correct values, but if I flash, the value for both positions is 0xFF, so again the clock frequency is not correct...
mmmm weird
Please also set the trim value on the debug configuration options
Debug configuration/Edit/Advance debug.../ and then select the value that you need for the internal clock
Please check the following picture
Thank you for your answer Vicente.
I asked also support to PEmicro, and according to what they say, when debugging, in my case with a Multilink, it's PEmicro's implementation and trimming works fine, but the "Flash File to Target" option is Codewarrior's implementation and this functionallity may not be implemented eventhough the option appears as well.
By the way, it seems that the Cyclone programmer has also the functionallity, so, in that case, the issue would be resolved. Soon I will have the oportunity to try it, so I will let you know.
Regards.
Indeed, the PEmicro's "Cyclone Image Creation" software has the posibility to calculate and program the trim value. I have tried it with a Cyclone FX and it works properly, so that solves my problem.
Thank you to all for your responses.