Looks like when you call OpenSerial for Com2 (at least on a 5282), that it clobbers the pin functions set up for the Rx and Tx lines before the call.
More specifically, since the UART2 functions are not the default functions for any of the associated pins, we attempted to configure those functions before calling OpenSerial for Com2. The 5282 UART2 Tx lines can be either J2:42 or 44, and the Rx can be either J2: 39 or 41. As a further detail, two of these pins (J2:39 and 42) are also used for the i2c: SDA and SCL, so they should probably be avoided.
Therefore, prior to calling OpenSerial, we tried to preconfigure the Rx and Tx and called:
J2[44].function(PINJ2_44_UTXD2);
J2[41].function(PINJ2_41_URXD2);
However, after then calling OpenSerial for COM2, the port did not work. It turns out we need to call OpenSerial first, then call the following to make everything OK:
J2[42].function(PINJ2_42_SCL);
J2[39].function(PINJ2_39_SDA);
J2[44].function(PINJ2_44_UTXD2);
J2[41].function(PINJ2_41_URXD2);
It seems to me that this is a bit flawed and that OpenSerial should perhaps not reconfigure pin functions? Perhaps it's unavoidable, but if so it would be nice if it were documented somewhere, so here it is.
OpenSerial for COM2 clobbers J2 pin functions?
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: OpenSerial for COM2 clobbers J2 pin functions?
In nburn\mod5282\system\serial.cpp
there are #ifdef to move the third serial port pin.
#defiine THIRD_ON_CAN (1)
at the begining of this file to change the default pin assignment.
Paul
there are #ifdef to move the third serial port pin.
#defiine THIRD_ON_CAN (1)
at the begining of this file to change the default pin assignment.
Paul