k40 irda reciver

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

k40 irda reciver

Jump to solution
1,106 Views
paulstanley
Contributor I

Hello. I wanted to create reciver capable of reading signals from remote control. I know only the basics. I managed to use GPIO as an transmitter (since it was as simple as:

PORTE_PCR26 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;

GPIOE_PDDR |= (1<<26);

but when comes to reciver i cannot find any sample or hints how to get it work: My code so far:

PORTA_PCR13 = PORT_PCR_MUX(1) | PORT_PCR_ISF_MASK | PORT_PCR_PFE_MASK | PORT_PCR_IRQC(11) | PORT_PCR_PE_MASK;

Im NOT sure about PCR13. I have found that PIN in SPF-27002_V5.pdf, I hope it is ok.

My general idea was to create interrupts with timestamps to read incomming signals but to be honest i cant find decent example of using interrupts on k40 either... I mean without Processor Expert i don't know how or where initialize them...

thanks for any help and sorry for bad grammar...

Labels (1)
0 Kudos
1 Solution
687 Views
anthony_huereca
NXP Employee
NXP Employee

Hi Paul,

  The code doesn't use the IrDa feature of the UART, it's a quick hack to use the comparator interrupt to read in the bits. The IrDa line on the K60 tower board is connected to the comparator input, so a comparator interrupt fires whenever the signal voltage changes (both rising and falling).

  That said, looking at it more, there is now an MQX driver for using the IrDa feature in the UART, so my recommendation would be just to use that driver instead of my code. Details are in C:\Freescale\Freescale_MQX_4_1\mqx\examples\irda

View solution in original post

0 Kudos
6 Replies
687 Views
anthony_huereca
NXP Employee
NXP Employee

Hi,

  Here's some code I wrote a long time ago that uses the IR receiver on the Kinetis K60N512 board. It should be able to be easily modified for a K40 board. It uses the HSCMP and LPTimer, though there are methods of doing it with the UART module itself.

  It was written as an MQX task, but all the code is bare metal so except for the interrupt part, it should be re-usable in any project. Take a look at the bare-metal example code for setting up interrupts.

-Anthony

687 Views
paulstanley
Contributor I

Thank for your help i almost managed to erease all errors from code (LPT -> LPTM0 and such) But i can't fix HSCMP macros. I mean i can't find proper macros in whole MK10DZ10.h. I can though find macros for CMP but i dont know if this is same comparator with some new way to initialize hight speed option?

0 Kudos
687 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Customer need to use CMP module macros definitions in MK10DZ10.h file.
Wish it help.

best regards,
Ma Hui

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

687 Views
paulstanley
Contributor I

I will click correct answer but i still have few questions :smileyhappy:

Firstly amh Could you point me place in your code where IrDa is initialised? I can see when counter and comparator are initialised and started but i cannot see part where data is transfered from irda to comparator for magic :smileyhappy:

i also saw in your code that you didn't used MQX IR driver since is not planned for kinetis, is this comment still valid or did something changed?

0 Kudos
688 Views
anthony_huereca
NXP Employee
NXP Employee

Hi Paul,

  The code doesn't use the IrDa feature of the UART, it's a quick hack to use the comparator interrupt to read in the bits. The IrDa line on the K60 tower board is connected to the comparator input, so a comparator interrupt fires whenever the signal voltage changes (both rising and falling).

  That said, looking at it more, there is now an MQX driver for using the IrDa feature in the UART, so my recommendation would be just to use that driver instead of my code. Details are in C:\Freescale\Freescale_MQX_4_1\mqx\examples\irda

0 Kudos
687 Views
paulstanley
Contributor I

Thank you for answer once again. I managed to get to work your code, cause it is more universal way (and i don't know even name for remote i use so i need to self-learn somehow his commands) The code works great but i noticed that interrupt never manages to get even 1 valid bit. Sometimes i get few rising edge interrupts, sometime only falling edge interrupts and im pretty sure they both should kick in to get valid_bit raised. I wonder if there is something wrong with remoter or i did something wrong with interrupt speed?

0 Kudos