STM32F20x USART3

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

Moderator: RoccoMarco

Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

STM32F20x USART3

Post by Tabulous »

Dont seem to be able to recieve data on USART3.

It is a 100 pin device and have it setup on PC10 and PC11, using alternate function 7.

I can send data out of USART3 ok using

chprintf((BaseSequentialStream*)&SD3, "Test String!! \r\n");

But i cant receive data, my recieve thread is this.

Code: Select all

static msg_t ThreadBacta(void *arg)
{
msg_t charbuf;
flagsmask_t flags;
BACTA_ST *ps = &pd;
EventListener elBactadata;

    (void)arg;

    chRegSetThreadName("bacd");
    sdStart(&SD3, &bactaconfig);

    chEvtRegisterMask((EventSource *)chnGetEventSource(&SD3),
                      &elBactadata, EVENT_MASK(1));

    while(TRUE)
    {
        bactaCommsHandler(ps);

        flags = chEvtGetAndClearFlags(&elBactadata);

        if(flags & CHN_INPUT_AVAILABLE)
        {
           do
           {
              charbuf = chnGetTimeout(&SD3, TIME_IMMEDIATE);

              if ( charbuf != Q_TIMEOUT )
              {
//                  chprintf((BaseSequentialStream*)&SD3, "%c", charbuf);

                  decodeBactaStatemachine( ps, (char)charbuf );
              }
           }
           while (charbuf != Q_TIMEOUT);
        }

        chEvtWaitOneTimeout(EVENT_MASK(1), MS2ST(10));
    }

    return( 0 );
}


decodeBactaStatemachine is never called, which i would except if there was data been recieved
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F20x USART3

Post by Giovanni »

Is the problem related to the code (it looks OK) or SD3 itself? you may try another USART.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: STM32F20x USART3

Post by Tabulous »

with relation to SD3. If i change to SD6 everything works oks.

As i said it seems to be the recieve on SD3 that is not firing an event ?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F20x USART3

Post by Giovanni »

It could be a bug, for example an ISR not linked correctly to its vector. I'll verify.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F20x USART3

Post by Giovanni »

I don't see obvious errors in the driver and definitions, are you using an F4?

Try putting a breakpoint into the ISR and see if it is triggered, if not verify the HW RX line (connected, conflicted etc).

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: STM32F20x USART3

Post by Tabulous »

F2 as per title of this post :-)

I can see data on Pin79 which is USART3_RX with scope, but i dont get any interrupts on

Code: Select all

CH_IRQ_HANDLER(STM32_USART3_HANDLER) {

  CH_IRQ_PROLOGUE();

  serve_interrupt(&SD3);

  CH_IRQ_EPILOGUE();
}
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F20x USART3

Post by Giovanni »

Is the UART3 RX signal declared alternate on a single pin? verify your board.h.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: STM32F20x USART3

Post by Tabulous »

PC10 and PC11 are set to Alternate 7, which is USART3_TX and USART3_RX respectively.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F20x USART3

Post by Giovanni »

Just PC10 and PC11 or you have some alt(7) on other pins? that is forbidden.

You may inspect the USART registers and see if some data is received but not handled by the driver. I doubt that, most likely the signal does not get to the USART for some reason.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: STM32F20x USART3

Post by Tabulous »

Right alt(7) is also use on another USART this might be the issue.....
Post Reply