2004-06-21 08:11 PM
2004-06-14 05:09 AM
Dear Sir ~
I am using ST6242, using interrupt to generate the toggle frequency. (Target = 2kHz square wave for buzzer). But I can not get the excected frequency. My setting: TSCR = 01101XXXB (XXX = PS0:2) PSC = 0XXXXXXXB (XXXXXXX=) TCR = 00000001B My expect and determination: Shortest Interrupt interval should be = 1 / (4Mhz / 12 / 1 ) = 3us / 12 means divide by 12 (refer to ST6242 spec page 18/70) /128 means divide by 128 (refer to ST6242 spec page 41/70) Shortest square freq = 1 / [3us (Hi) + 3us (Lo)] = 166kHz PS(0:2)=000,PSC(0:7)=00000000>Result Freq=166kHz,interval=3us My result: PS(0:2)=000,PSC(0:7)=00000000>Result Freq=500Hz, interval=843us PS(0:2)=001,PSC(0:7)=00000000>Result Freq=309Hz, interval=1.6ms PS(0:2)=010,PSC(0:7)=00000000>Result Freq=158Hz, interval=3ms PS(0:2)=011,PSC(0:7)=00000000>Result Freq=80Hz, interval=6ms PS(0:2)=100,PSC(0:7)=00000000>Result Freq=40Hz, interval=12ms PS(0:2)=101,PSC(0:7)=00000000>Result Freq=800Hz, interval=562us PS(0:2)=110,PSC(0:7)=00000000>Result Freq=1.2kHz, interval=386us PS(0:2)=111,PSC(0:7)=00000000>Result Freq=1.0kHz, interval=456us In my testing above, I cannot find a setting can meet my expectation. Is it my concept wrong? Can you please help in coding? My Tools=ST6240B-EMU2, Compiler=RIDE Thanks Best Regards Lai2004-06-21 08:11 PM
With the TCR you can the 500Hz multiply by 4! so you can make 2Khz.
But for the calculation for the timers, i use always an excel sheet. It's an automatic calculation after delay time insertion. I attached the excel sheet. ________________ Attachments : ST6-Timer.xls : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Ev&d=%2Fa%2F0X0000000bXK%2FN_qhflHQ5TTpim4nY6SBletov2oJMvgIeq08B_Q4KP8&asPdf=false