I'd like to use the hw configurator to generate Initdevices.c for using UART1.
I would like the TX and RX to come out of the header pins on the expansion header of the EMF8UB2.
The examples for UART1 in the Simplicity studio seem to use P0.4 and P0.5 (which are normally assigned to UART0). Yes I'd like to use UART0 as well for a different reason (as well as SPI0 for the LCD). I guess I don't understand the Crossbar very well.
1. Do I move the UART1_TX and UART1_RX to P2.1 & P2.2 (as the schematic says).
2. Is there an easy way to move this (Complexity Studio seems to make me type in Skip each pin till it lands on a the PIN you want).
3. Where is the Interrupt arriving (Is it considered external and do I need to field external interrupts)?
4. Is there sample code for register to MASK/Unmask for stopping/unstopping UART1 interrupts (required to protect code outside ISR).
All the examples for UART1 did not deal with Interrupt driven system. They simply showed polling the UART1 registers.
You can move the UART1 pins to any position on the header you want, the EXP header pinout is our standard for expansion boards. The best way to move the pins is to skip one pin at a time until the UART pins are where you want them (UART0 is treated differently by the crossbar and is always P0.4 and P0.5). Interrupts for UART1 are controlled by the SCON1 register, there are interrupts for TX and RX, see section 21.4.1 of the reference manual for more information.
Thanks Joe for the response. I guess my big problem is that I do not understand the Crossbar.
I could not figure out for example: Have UART1_RX on P2.2 - What registers are set to say
UART1_RX are on that pin and not on any other pin.
What sets P2.2-INPUT= UART1_RX? (Yes I got the part of P2.2 being set to Digital Open Drain).
I did read the RM on SKIP etc (again - not sure what is being Skipped).
My big issue is that I have complex examples (with LCD etc) working with UART0, But I am tasked to get it on UART1 on the expansion header. My code never seems to enter the ISR for UART1.
I have tied the Expansion Header RX to the TX of a CP2104-EK (UART to USB) kit, and am testing with Tera Term.
My settings (in Initdevices):
P0 = P0_B0__LOW | P0_B1__HIGH | P0_B2__HIGH | P0_B3__HIGH | P0_B4__HIGH
| P0_B5__HIGH | P0_B6__HIGH | P0_B7__HIGH;
P0MDOUT = P0MDOUT_B0__PUSH_PULL | P0MDOUT_B1__OPEN_DRAIN
| P0MDOUT_B2__OPEN_DRAIN | P0MDOUT_B3__OPEN_DRAIN
| P0MDOUT_B4__PUSH_PULL | P0MDOUT_B5__OPEN_DRAIN
| P0MDOUT_B6__PUSH_PULL | P0MDOUT_B7__OPEN_DRAIN;
P0SKIP = P0SKIP_B0__SKIPPED | P0SKIP_B1__SKIPPED | P0SKIP_B2__SKIPPED
| P0SKIP_B3__SKIPPED | P0SKIP_B4__NOT_SKIPPED
| P0SKIP_B5__NOT_SKIPPED | P0SKIP_B6__NOT_SKIPPED
P1MDOUT = P1MDOUT_B0__PUSH_PULL | P1MDOUT_B1__OPEN_DRAIN
| P1MDOUT_B2__OPEN_DRAIN | P1MDOUT_B3__OPEN_DRAIN
| P1MDOUT_B4__PUSH_PULL | P1MDOUT_B5__OPEN_DRAIN
| P1MDOUT_B6__PUSH_PULL | P1MDOUT_B7__PUSH_PULL;
P1MDIN = P1MDIN_B0__DIGITAL | P1MDIN_B1__DIGITAL | P1MDIN_B2__DIGITAL
| P1MDIN_B3__DIGITAL | P1MDIN_B4__DIGITAL | P1MDIN_B5__ANALOG
| P1MDIN_B6__DIGITAL | P1MDIN_B7__DIGITAL;
P1SKIP = P1SKIP_B0__NOT_SKIPPED | P1SKIP_B1__SKIPPED | P1SKIP_B2__SKIPPED
| P1SKIP_B3__SKIPPED | P1SKIP_B4__SKIPPED | P1SKIP_B5__SKIPPED
| P1SKIP_B6__SKIPPED | P1SKIP_B7__SKIPPED;
P1 |= 0x10; /* Display Enable */
P2MDOUT = P2MDOUT_B0__PUSH_PULL | P2MDOUT_B1__PUSH_PULL
| P2MDOUT_B2__OPEN_DRAIN | P2MDOUT_B3__OPEN_DRAIN
| P2MDOUT_B4__OPEN_DRAIN | P2MDOUT_B5__OPEN_DRAIN
| P2MDOUT_B6__OPEN_DRAIN | P2MDOUT_B7__OPEN_DRAIN;
IE = IE_EA__DISABLED | IE_EX0__DISABLED | IE_EX1__DISABLED
| IE_ESPI0__ENABLED | IE_ET0__ENABLED | IE_ET1__DISABLED
| IE_ET2__ENABLED | IE_ES0__ENABLED;
EIE2 = EIE2_ESMB1__DISABLED | EIE2_ET4__DISABLED | EIE2_ET5__DISABLED
| EIE2_ES1__ENABLED | EIE2_EVBUS__DISABLED;
IE = 1 (later).
Note My devices are:
UART0, SPI0, UART1, LEDs (GRB - on P1.6,P1.7,P2.0), BTNS (P0.2,P0.3) - Basically stuff on UB2
Got everything working on UART0, now need to add UART1. No luck on UART1 - Can't see input ISR.
The crossbar directs digital IOs to the pins in a fixed order. Skipping a pin makes that pin available for GPIO or analog functions, and the crossbar "skips" that pin and goes on to the next one. Skipping is handled by the PxSKIP register. It can be confusing, so we recommend tools like configurator to handle pin assignments.
Regarding the UART1 interrupt, is the interrupt enabled in EIE2? Are global interrupts enabled? Are you able to send and receive data from the UART1 port without using interrupts?
It can be confusing,
however it is ESSENTIAL to understand it and thus, saying "I do not need to know, the configurator handles it" is folly.
Found the problem. Missing the REN bit in UART1 control.
Solved - Thanks Joe for your early help.
The feature of the crossbar that you explained is fundamental in understanding this. I was under the impressing that the crossbar meant some sort of multiplexer (that I've seen on other mcu's). I did not realize that the functions are in a specific order and are assigned to PINs in that order. The concept of SKIP all makes sense now.
As always - When in a hurry, I don't bother to read the Manual carefully, and get stuck for days, and finally am forced read the manual. When will I learn to invest time in reading the manual first :-)