MicroCode Studio allows you to receive and transmit serial data when the ICD process is executing. Serial data can be sent to a PICBasic HSERIN instruction using the ICD Serial In window. Serial data sent by a HSEROUT instruction is received and displayed using the ICD Serial Out window.
It is essential that MicroCode Studio takes complete control of the microcontrollers hardware serial port (USART), to ensure that the ICD functions correctly. A USART that is not configured properly could compromise the ICD process. Certain user defines are therefore disabled during an ICD Compile or ICD Compile and Program and include:
The ICD will only disable hardware serial defines if they are present in your main program. MicroCode Studio will not disable defines if they are present in an include file. Using hardware serial defines in an include file may, in certain circumstances, cause the ICD process to fail. In addition, the MicroCode Studio ICD will only support HSERIN and HSEROUT if they are used from within your main program block.
The MicroCode Studio ICD uses the default PICBasic serial data format of 8 data bits, no parity and one stop bit (8N1) to communicate with your computer. In addition, the following defines are used:
You won't see these values normally, but you can view the actual values used by the MicroCode Studio ICD by right clicking on the ICD Explorer window and then selecting 'ICD Serial Settings...' The ICD also uses the following RCSTA value, which is a default PICBasic define:
This means that when using the ICD, you do not need to configure HSERIN and HSEROUT as you would normally, because the ICD will do this automatically. However, you may need one or more of the above defines in your final code build, if HSERIN and HSEROUT are used.
Here is a simple program, which reads in a value using HSERIN and then echoes it to screen using HSEROUT. It assumes you are using a microcontroller running at 20MHz, programmed with bootloader software.
The above program will run within the ICD process, but not if you compile and program your microcontroller normally (that is, you have not used ICD Compile or ICD Compile and Program). You can view the defines MicroCode Studio has used by right clicking on the ICD Explorer window and then selecting 'ICD Serial Settings...'
If you want to use HSERIN and HSEROUT in your final program, then just add the above defines to your source code. For example,
Page up-dated at December 13, 2003
Via dell'Artigiano, 8/6
40016 San Giorgio di Piano
Tel: +39 051 892.052 (4 lines)
FAX: +39 051 893.661
Home Index Software Tables Cat. Index