Code porting problems from IAR to Codewarrior for MC9S12XD64

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

Code porting problems from IAR to Codewarrior for MC9S12XD64

1,495 次查看
alistair_toppin
Contributor I
Afternoon all.
 
I have recently started developing code for a dot matrix display. Initially this occured with the IAR compiler and a MCS912DJ256B processor but have had to upgrade to the MCS12XD64 and codewarrior as the project progressed. In doing so, I have noticed that the same code that originally worked for generating PWM signals from the compare module (using IAR and DJ2566) went from 622us per period to 3.48ms per period (on XD64 using CodeWarrior)
 
I coded the original version based using the datasheet for the XD64 processor as I knew I'd eventually have to upgrade and this worked fine with IAR so cannot see how things are not working the same now.
 
To my knowledge I've written all the registers correctly and have double checked prescaler values etc. (no prescalers have been used and my 16MHz external clock is being divided down to having 4.9us instruction cycles against the expected 125ns.
 
Can anyone suggest something which I may have missed out that could account for this drastic change of execution speed?
 
Many thanks
 
99
标签 (1)
0 项奖励
回复
1 回复

762 次查看
alistair_toppin
Contributor I
Perhaps I should ammend my previous post with a little more detail. The following is my initialisation where PWM_PERIOD is 4976 and LOAD_PERIOD is 100. The target oscillator is 16MHz.
 
Code:
void CAPTURE_COMPARE_initialise(void){  TIOS = (1<<IOS0) | (1<<IOS1) | (1<<IOS2) | (1<<IOS7);  /* set CCP 0, 1, 2, and 7 as compare */  TSCR1 = (1<<TEN);   /* enable the timer*/  /* SET THE PIN MODES to clear on match for ROWEN and set on match for COLEN   */  TCTL2 =  (1<<OM0) | (0<<OL0) | (1<<OM1) | (1<<OL1);  /* set the prescaler */  TSCR2 = 0; /* set the main timer to reset on a channel 7 compare (modulus up counter with  * period set by capture 7 register also create the pwmPeriod interrupt  */  TSCR2 |= (1<<TCRE);  TC7 = PWM_PERIOD;  /* If you want to disable the period match interrupt, uncomment the following   */  TIE |= (1<<7); /* set the action of the output pins on a TC7 match.  * OC7M is the mask to select which pins will be effected  * OC7D is the bit value to set the output pin to on a timer 7 compare  */  OC7M = (1<<0) | (1<<1);  OC7D = (1<<0) | (0<<1);/* compare interupt for channel 2 used to the next upload sequence */   TIE |= (1<<2);   TC2 = PWM_PERIOD - LOAD_PERIOD;   /* set the brightness to mid rnage */   (void)CAPTURE_COMPARE_setPwm(DISPLAY_ZERO, (U16)1048);}

 
Thanks in advance
 
99
0 项奖励
回复