S12XE TIM Output Compare Set and Clear Pins

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

S12XE TIM Output Compare Set and Clear Pins

Jump to solution
857 Views
rayhall
Contributor V

I am trying to use TIM to charge and then discharge an ignition coil. I have spent many hours trying to get the output compare to work. All the examples I can find toggle the pin on compare. None show how to set and clear the pins.

What I required  is to enable the OC to interrupt in the future to set the pin. In the interrupt the next interrupt period is set to clear the pin.

 

I have attached my attempt that will do this only one time.

 

Ray.

 

 

Please do not mark this question as "presumed answered" until I have confirmed this to be true.

Original Attachment has been moved to: TIM_OutputCompare.zip

Labels (1)
0 Kudos
1 Solution
610 Views
rayhall
Contributor V

Hello Ladislav,

I now have it working !!!!

The problem was the PIT interrupt was not working. For some reason, the changes you made to the PIT stopped it working, so the tickTimer in the main loop was never used.

I have cleaned up the code and have attached the files. I am sure it would be helpful to others if NXP made an example or modified my code and made it available. For me it has been two weeks of trying to get it to work. An example would have been so helpful.

Thank you for your help.

Ray.

View solution in original post

0 Kudos
7 Replies
610 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

could you please send me all numbers and text you can see on the top of the device.

Have you check functionality of the PTR.0 n the GPIO mode?

Just set:

DDRR_DDRR0 = 1; // set pn as an output

PTR_PTR0 = 1;

PTR_PTR0 = 0;

PTR_PTR0 = 1;

PTR_PTR0 = 0;

Then just step the code through instructions and check whether you are on the correct pin.

(I do not have 208 MAPBGA device so I had to route the TIM to the port P. I spent 2 hours trying to find why I do not have signal on PP0 because I forgot to route the TIM 0 to port P)

Are you able to test the code I sent to you and look whether port P0 is working well?

Best regards,

Ladislav

0 Kudos
611 Views
rayhall
Contributor V

Hello Ladislav,

I now have it working !!!!

The problem was the PIT interrupt was not working. For some reason, the changes you made to the PIT stopped it working, so the tickTimer in the main loop was never used.

I have cleaned up the code and have attached the files. I am sure it would be helpful to others if NXP made an example or modified my code and made it available. For me it has been two weeks of trying to get it to work. An example would have been so helpful.

Thank you for your help.

Ray.

0 Kudos
610 Views
rayhall
Contributor V

Ladislav,

DDRR_DDRR0 = 1; // set pn as an output

PTR_PTR0 = 1;

PTR_PTR0 = 0;

PTR_PTR0 = 1;

PTR_PTR0 = 0;

This gives no output on pin PR0

This works and turns the output on and off.

DDRR = 0x01;
PTR = 0x01;

PTR = 0x00;

PTR = 0x01;

PTR = 0x00;

Ray.

0 Kudos
610 Views
rayhall
Contributor V

Ladislav,

If I setup the Output Compare to toggle on Interrupt I get output on pin PR0. Also if I do what you ask I also get an output on the pin.

The text on the chip is S12XEP100CVL It is the 205 pin BGA version.

Ray.

0 Kudos
610 Views
lama
NXP TechSupport
NXP TechSupport

So,

I see the issue in the port routing.

I have adjusted your code. The pronciple you use is OK. I can see correct behaviour at the scope.

Please search for keyword LAMA to see what I changed/added in/to the code.

Best regards,

Ladislav

0 Kudos
610 Views
rayhall
Contributor V

Ladislav,

You wrote

I am not sure what you want to say here because PTT is not a port for TIM. It is PP.
 Moreover, writing to timer port when OC is enabled has no meaning. In this case you have to use CFORC register
 with proper compare action setup. - LAMA

I am not trying to directly write to the port pins in the interrupt. I forgot to delete  "PTT = 0x00;" Sorry..

I want the output compare interrupt, to set and clear the pin PR0 on Port R. I added the following and I still do not get any output on PR0.

TIM_CFORC = 0x01;   // Force Output Compare Action for Channel 0

Ray.

0 Kudos
610 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

I am going to prepare you an example with TIM.

However, if I were you I would use for this kind of a task I would use a PIT timer.

Best regards,

Ladislav

0 Kudos