Xgate semaphore MC9S12XDP512

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

Xgate semaphore MC9S12XDP512

1,339 Views
Claire
Contributor I

Hello,

 

I use bus CAN for receive data and with this I generate a signal (with ECT)

For this I use interruption but I want 250ns for my signal period and I have 32µs (with PLL clock - 16MHz).

 

I would like to reduice this period and for do this I want to use semaphore to replace interuption.

But I don't know How do this.

 

Actualy, I stock receive_data in circualr buffer after to read data and generate signal by interruption. but It's too long.

 

In the documentation I read that for use semaphore I must use XGSEM, SSEM and CSEM. But I don't find how to use this register.

 

Thank you in advance,

Original Attachment has been moved to: main_buff.c.zip

Labels (1)
0 Kudos
15 Replies

1,000 Views
RadekS
NXP Employee
NXP Employee

In attachment you can find simple exaple code for semaphores at S12XDP512.

I hope it helps you.

0 Kudos

1,000 Views
Claire
Contributor I

Thank you for your code.

Thank's to your code, I understand how semaphore works, but I don't think I can reduce the signal period. I must find another solution.

0 Kudos

1,000 Views
kef
Specialist I

I wonder why did you attach CPU12X code instead of XGATE code.

250ns period is too optimistic for most of MCU's. I think you need programmable logic for this task.

0 Kudos

1,000 Views
Claire
Contributor I

I must have 250ns for my projet. And I just have starterkit SK-S12XDP512-A.

It's impossible to have 250ns for 1 period with just this MCU ?

I can increase the period up to 400ns but It's maximum value. It's too optimistic again ?

0 Kudos

1,000 Views
kef
Specialist I

It is the best to generate continuous 1/250ns clock using PWM channels or ECT timer set up to produce continuous clock without CPU attention.

It is totally not clear for me what are you trying to do. You attached code is too far from your description and 250ns.

BTW, why so low PLL clock? Also, do you mean 16MHz PLL clock and 8MHz bus clock, right?

0 Kudos

1,000 Views
Claire
Contributor I

For my project, I must create wave signal with data that I received by bus CAN.

I must have 400 ns resolution for the output signal.

To verify this resolution, I send value "1" in bus CAN and I mesure output signal's period. But I don't find 400 ns.

For have this period, I try to change clock (after I use 4MHz and now 16MHz) but I still do not get the right value.

Now, I have a bus clock of 8MHz.

So I wanted to change some functions to further reduce the period. For example use a semaphore instead of interruptions.

0 Kudos

1,000 Views
kef
Specialist I

400ns resolution doesn't mean 2.5MHz or 1.25MHz square wave. Resolution is the minimum time step, by which you may widen or shorten some timing. On S12XD you may produce waveforms with 25ns resolution, but still have problems generating ~MHz waveforms.

It is not clear what kind of waveforms are you going to produce.

0 Kudos

1,000 Views
Claire
Contributor I

I want produce square signal in output. For that I use function output compare.

With my programme how can I produce signal with 400 ns resolution max ?

How can I verify this resolution on output signal ?

0 Kudos

1,000 Views
kef
Specialist I

For square wave output I would better use PWM hardware, no interrupts, no CPU load.

0 Kudos

1,000 Views
Claire
Contributor I


Ok, I try to replace interrupt by PWM but error message appear when I launch compilation.

message "ILLEGAL_BP" I thought this error message concern only Interrupt, I don't understand.

0 Kudos

1,000 Views
Claire
Contributor I

Apparently this is not it. When I remove the initialization of the interrupt message is still there.

0 Kudos

1,000 Views
kef
Specialist I

Then what about still enabled timer channel interrupts and not interrupt handlers?

0 Kudos

1,000 Views
Claire
Contributor I

.... :smileyconfused: I forgot that ...

Ok It's better. I have pwm signal. But it does not correspond to my specifications.

I'll have to find something else.

Thank you for your help !!

0 Kudos

1,000 Views
RadekS
NXP Employee
NXP Employee

Maximum source frequency for PWM is bus clock.

Maximum output PWM frequency is bus clock/2 ...PWMPERx=0x02, PWMDTYx=0x01

In your case (8MHz bus clock), smaller step = 125ns and maximum output freqency is 4MHz.


0 Kudos

1,000 Views
kef
Specialist I

ILLEGAL_BP usually occurs when code runs away. I guess it is caused by enabled PWM shutdown interrupt and (?) no interrupt handler for this interrupt.

0 Kudos