Timings in your code are wrong....
It may just be a typo but the timings shown in your code are an order of magnitiude out.
SONY Timings are as follows
Header pulse is 2400uS ON 600uS OFF
Logic One is 1200uS ON 600uS OFF
Logic Zero is 600uS ON 600uS OFF
You show a "1" as 120uS and a "0" as 60uS
Remember also that the signal you are receiving will be a modulated 40kHz carrier and you need an IR Receiver Module to give you a demodulated signal which is normally ACTIVE LOW.
Pulsein varies with OSC frequency so ensure that you correctly define the OSC and allow for the fact that at higher frequencies the count for a given pulse length will be greater.
eg as Sony is based on a 600uS timeframe then Pulsin would be
4MHz = 10uS resolution = Count of 60, 120, 240
10MHz = 4uS resolution = Count of 150, 300, 600
20MHz = 2uS resolution = Count of 300, 600, 1200
40MHz = 1uS resolution = Count of 600, 1200, 2400
Use those values as the centre values for your acceptance window eg @ 20MHz 270-330, 540-660, 1080-1320 allowing a 10 percent tollerance.
Hope that helps
Keith
Keith
www.diyha.co.uk
www.kat5.tv
Bookmarks