detect PWM on Port T and relay it to Port P

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

detect PWM on Port T and relay it to Port P

1,099 Views
gokilz
Contributor I

Hello everyone,

 

i need to detect PWMs on port T (The PWMs are from other board) and need to relay the PWMs to port P.

I use MC9S12XDP512MAG on my board.

has anyone any idea?

My first idea would be with Enhanced Capture Timer.

 

Thanks before.

Labels (1)
Tags (1)
0 Kudos
5 Replies

615 Views
Fast
Contributor IV

This is an ideal task for XGATE, read and write in endless loop, but why waste powerful ports like ECT and PWM.

Rich A

0 Kudos

615 Views
gokilz
Contributor I

Hi Rich,

sorry for my lately reply.

Can you give me some clue, how can i make it work?

Zef

0 Kudos

615 Views
kef2
Senior Contributor IV

Zef,

CW project wizard generated XGATE enabled project enables XGATE and triggers XGATE software interrupt, which is triggered to run again and again. You need to modify SoftwareTrigger0_Handler in xgate.cxgate and place there code to read PTIT bit and copy it to PTP bit.

This should work for low freq. PWM's.

Please keep in mind however that you need to either have nothing else connected to port P pins (only copied PWM), or use XGSEM register from CPU12X code and csem() / ssem() calls from XGATE code to prevent simultaneous accesses to PTP register. Else weird things may happen.

0 Kudos

615 Views
gokilz
Contributor I

Hi Edward,

thanks for your clue. I can now relay the PWM. Now i want to know, how can i calculate the dutycycle of the PWM?

I've already made a counter for the Ton and Toff, then calculate it for the dutycycle. But somehow it doesn't work.

Has anyone idea?

Thanks

0 Kudos

615 Views
kef2
Senior Contributor IV

Zef,

you may use ECT input capture to measure pulse width and period.

0 Kudos