Signal Generation / Timers

Discussion to talk about software related topics only.
Post Reply
DBrunermer
Posts: 67
Joined: Thu Apr 21, 2011 7:06 am
Location: Pittsburgh, PA

Signal Generation / Timers

Post by DBrunermer »

Hello,

I need to create a pulsed signal 10 microseconds long, but at a frequency of 5kHz ( T=200 microseconds).

I don't think it's possible with the PWM. At least, not if I've understood the manual. I was thinking that, instead, I would use two timers to make this signal. One timer would drive the underlying frequency, and it will generate an interrupt, and in the interrupt, I set the outpin of the other timer to the high state (e.g.) and have that timer in the 'toggle output' mode so that it would switch it back off when the second timer terminates.

Is there a better idea?
MOD 5272, Eval Kit V1.12

Thanks,
Dan B.
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: Signal Generation / Timers

Post by lgitlitz »

I just did a quick experiment with the PWM on that processor and it seems that I can get either a 130uS period or a 260uS period. The 20uS pulse can be achieved in either one. Would one of these work for you?
5K interrupts per second is questionable on this processor, test it out. Overall the idea sounds fine if you can spare all the CPU time that will be required. You probably should use a level 6 interrupt so it is not masked out when interrupts occur on serial or Ethernet peripherals. This will keep your timing more consistent.
DBrunermer
Posts: 67
Joined: Thu Apr 21, 2011 7:06 am
Location: Pittsburgh, PA

Re: Signal Generation / Timers

Post by DBrunermer »

Thanks for the reply.
Unfortunately, no, it really has to be 8 to 10 microseconds. If I'm doing the math right, 5kHz should leave me 12,500 clocks between events, and inside each event, I really only need to re-establish the pulse, and write 32 eight bit bytes to a port. I know it's fetch, write, loop compare, but I think all in all it's got to be less than 1000 CPU cycles. I'm also thinking that, if I need to, I can upgrade to the MOD5270, and still do what I need.
For my idea to work, though, I need to be able to control the TOUT1 pin directly. Do you know if that's possible?
Thanks again,
Dan B.
Post Reply