MC9S12C64MFA Port T set up question

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MC9S12C64MFA Port T set up question

ソリューションへジャンプ
228件の閲覧回数
roberthiebert
Contributor IV

MC9S12C64MFA, Code Warrior 5.9.0, coding in assembler.

I am setting up Port T but I'm not sure I'm doing it right. Here is what I am trying to accomplish:

PT0 is for PWM control of a solenoid valve.

PT3 is a general purpose output.

PT1,2 4,5,6,7 are all output compare channels. All are under port control with interrupt on compare match enabled. When I load the output compare value I will set the associated pin to the appropriate state. When the match occurs and the interrupt is triggered I will set the pin to the appropriate state in the ISR.

Here is what I have so far:

movb #$FF,DDRT ; All pins outputs

movb #$01,MODRR ; PWM control on PT0, PT1,2,3 on Timer control

movw #$0000,TCTL1 ; All pins under port control

movb #$F6,TIOS ; Output Compare on PT1,2,4,5,6,7

movb #$01,PWME ; PWM control on PT0

 

Should this work?

 

Regards,

Robert

 

0 件の賞賛
1 解決策
207件の閲覧回数
roberthiebert
Contributor IV

My goodness, I sure had that wrong! Thanks so much for the detailed explanation. As soon as I get my PCB finished I'll try that out.

Regards,

Robert

元の投稿で解決策を見る

0 件の賞賛
3 返答(返信)
169件の閲覧回数
yihanef
Contributor I

Game modes and events include team play, survival elimination, and seasonal tournaments planet clicker 3 online.

0 件の賞賛
210件の閲覧回数
lama
NXP TechSupport
NXP TechSupport

Hi,

I tried to do it without test. You can compare.

 

If the alternative function (another from GPIO) is enabled it takes precedence over all enable peripherals at pin with less priority. Priority starts from GPIO (the least) in the pin description table.

When you disconnect TIM from pin and you want to control them as output by SW
in the interrupt(not by automatic OC function) then you have to set it as GPIO output mode.

// set ports
PTT = ; // good to set initial value at the pins before
// it is switched from input(default) to output
DDRT = 0xFE; // pin 7,6,5,4, ,2,1 are driven by SW, pin 0 driven by PWM
// pin 3 is also output in GPIO mode

//select pins connections
MODRR = 0B00000001 // TIM,TIM,TIM,TIM, GPIO,TIM,TIM,PWM

// select TIM function
TCTL1 = 0x00; // The TIM is disconnected from pins, value will be set manualy
TIOS = 0xFE // TIM channels 7,6,5,4,3,2,1 in OC function

// Set PWM parameters, period, duty, polarity

....

// Set TIM parameters .. predcaler, period, OC value

....

// enable interrupt for TIM
TIE = 0B11100110; // enable TIM interrupt for channel 7,6,5,4, 2,1

//enable interrupt globally
asm CLI

// Run timer, set debug possibilities, set fast flag clear for TIM
TSCR1 = 0xF0; // TEN-run timer; (TSWAI,TSFRZ)-good to set
// to be able to debug; fast TIM flags clear,x,x,x,x

// Run PWM_0
PWME = 0x01; // run PWM0 at PT0

 

Best regards,

Ladislav

0 件の賞賛
208件の閲覧回数
roberthiebert
Contributor IV

My goodness, I sure had that wrong! Thanks so much for the detailed explanation. As soon as I get my PCB finished I'll try that out.

Regards,

Robert

0 件の賞賛