IRDA over Serial on STM32F103

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Selrak
Posts: 8
Joined: Mon Mar 25, 2013 10:10 am

IRDA over Serial on STM32F103

Post by Selrak »

Hey all,

So I have two systems, each with an IRDA emitter/receiver/transceiver soldered to UART pins on an STM32F103, along with a general purpose serial output which I plug into my computer for debug purposes.
Now I can't get these to communicate ! I have setup both serials, one with a regular 9600 bauds/sec config, the other with the same rate but with the "UART_CR3_IREN" mask on the last SerialConfig structure member, and made sure the "ShutDown" pin on my IRDA device was cleared. What am I missing ? Or should I look for board.h definition errors ?

Note : the macro at the beginning changes the behavior from IRDA emitter to IRDA receiver. The receiver sends 'r' after every 5 sec timeout on the IRDA serial, the emitter just sends 'x' all the time.
Note 2 : I do receive the receiver's 'r's (along with an unknown character) every 5 seconds. But no 'x' ...

Thanks in advance for the tips and help ! You guys rock and I love Chibi.

Code: Select all

#include "ch.h"
#include "hal.h"

#define EMITTER 1

// Serial configs : enable IRDA for one, and use a normal config for the other
static const SerialConfig irda_cfg = {9600, 0, 0, USART_CR3_IREN};
static const SerialConfig normal_cfg = {9600, 0, 0, 0};

int main (void) {

        halInit();
        chSysInit();
           
        // Make sure IRDA is on (ShutDown at 0)
        palClearPad(GPIOA, SD_IRDA2);

        // IRDA2 on PC10/11 through USART3
        sdStart(&SD3, &irda_cfg);
        // Output serial
        sdStart(&SD1, &normal_cfg);



        while(1) {
                if(EMITTER) {
                        sdPut(&SD3, 'x');
                }   
                else {
                        sdPut(&SD1, 'r');
                        sdPut(&SD1, sdGetTimeout(&SD3, 5000));
                }   
        }
}
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: IRDA over Serial on STM32F103

Post by Giovanni »

Hi,

Are the TX pins of both USARTs configured as alternate in your board.h file? try watching the TX signals using a scope or a logic analyzer.

Giovanni
Post Reply