chipKIT® Development Platform

Inspired by Arduino™

IRDA UART tested and working PIC32MX270F256D

Created Wed, 03 Oct 2018 21:28:34 +0000 by gh0stwriter


gh0stwriter

Wed, 03 Oct 2018 21:28:34 +0000

HardwareSerial *IrSerial = &Serial0;

IrSerial->begin(19200);
U1MODEbits.IREN = 1; //U2MODEbits.IREN = 1; for Serial1

And that's all you need. I have noted that the UART is using 3/16 encoding whereas a MCP2120 uses much shorter pulse widths, pulse spacing is identical however,and they talk to each other just fine. Note that when using the built in UART instead of the external MCP2120 encoder/decoder chip you'll see your own output echoed back on RX while you are transmitting and must ignore this.

Also I like to created a pointer to my Serial object so I can name is as I like, then just make calls to it with -> .


Brumley

Tue, 11 Dec 2018 11:43:23 +0000

What role does pulse widths length play in all this btw?


gh0stwriter

Thu, 20 Jun 2019 22:54:47 +0000

Sorry for the late reply.

The maximum pulse width according to the IRDA spec is 3/16th of a bit. So most encoders/decoders are just implemented in a state machine that runs at 16x the baud rate... which is super simple to do. The MCP2120 probably just waits 1 or 2 states instead of 3 but it still works fine... you're output pulse is just shorter, this would only ever be a problem if for some reason your pulse width became too short for your reciever to see etc... but that is not typicaly of the hardware.