MC9S08QG8 SCI baudrate veriation when flashing

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S08QG8 SCI baudrate veriation when flashing

Jump to solution
3,751 Views
egoitztoledo
Contributor III

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.

0 Kudos
Reply
1 Solution
3,688 Views
egoitztoledo
Contributor III

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.

View solution in original post

0 Kudos
Reply
8 Replies
3,746 Views
Nouchi
Senior Contributor II

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

 

3,740 Views
egoitztoledo
Contributor III

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.

egoitztoledo_0-1612773225009.png

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.

egoitztoledo_1-1612773487380.png

I wonder why the PE doesn't generate that code if it give you the option to select it...
Anyway, thank you again.

 

0 Kudos
Reply
3,729 Views
egoitztoledo
Contributor III

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?

0 Kudos
Reply
3,726 Views
vicentegomez
NXP TechSupport
NXP TechSupport

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.

 

0 Kudos
Reply
3,710 Views
egoitztoledo
Contributor III

Hello Vicente,

I really appreciate your answer, but I have already tried that as PE generates the code.

egoitztoledo_0-1612851292951.png

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...

 

0 Kudos
Reply
3,698 Views
vicentegomez
NXP TechSupport
NXP TechSupport

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

vicentegomez_0-1612908060412.png

 

0 Kudos
Reply
3,689 Views
egoitztoledo
Contributor III

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.

0 Kudos
Reply
3,626 Views
egoitztoledo
Contributor III

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.

0 Kudos
Reply