Embedded Systems Building Blocks, Second Edition

If you write a foreground/background application you will need to use the COMM_PC (assuming you are using a PC) and the COMMBGND modules. The first thing you need to do is to configure the module by setting the value of the #defines described in section 11.08. Next, you will need to call functions to initialize the modules and the serial port(s) that you are planning on using. For example, if you are using the PC's COM1, you would need to have the following code:
void main(void){ . . CommInit(); /* Initialize COMMBGND */ . . CommCfgPort(COMM1, 9600, 8, COMM_PARITY_NONE, 1); CommSetIntVect(COMM1); /* Install the interrupt vector */ CommRxIntEn(COMM1); /* Enable receive interrupts */ . .} <a name="948"></a><a name="beginpage.253EE025-D733-11D7-B210-00055D0AFCF5"></a>You should note that you don't need to enable transmit interrupts because this is done automatically when you send data on the serial port. When all your initialization is done, your background loop could check for incoming data, as...