1 /*-------------------------------------------------------------------------
2 support.c - startup for PIC14 regression tests with gpsim
4 Copyright (c) 2006-2010 Borut Razem
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding!
23 -------------------------------------------------------------------------*/
27 #include <pic16f877.h>
29 static unsigned int __at(0x2007) _config
= _WDT_OFF
;
37 /* wait until the transmit buffer is empty */
46 /* load and configure the libgpsim_modules module */
48 ;; Set frequency to
20MHz
49 .direct
"e", ".frequency=20e6"
51 ;; Load the USART library
and module
52 .direct
"e", "module library libgpsim_modules"
53 .direct
"e", "module load usart U1"
56 .direct
"e", "node PIC_tx"
58 ;; Tie the USART module to the PIC
59 .direct
"e", "attach PIC_tx portc6 U1.RXPIN"
61 ;; Set the USART module
's Baud Rate
62 .direct "e", "U1.rxbaud = 9600"
64 ;; Display the received character on terminal
65 .direct "e", "U1.console = true"
68 /* USART initialization */
69 PORTC |= 0x40; // Set TX pin to 1
70 TRISC &= ~0x40; // TX pin is output
72 //1. Initialize the SPBRG register for the appropriate
73 // baud rate. If a high speed baud rate is desired,
74 // set bit BRGH (Section 16.1).
78 //2. Enable the asynchronous serial port by clearing
79 // bit SYNC and setting bit SPEN.
83 //3. If interrupts are desired, set enable bit TXIE.
84 //4. If 9-bit transmission is desired, set transmit bit
85 // TX9. Can be used as address/data bit.
86 //5. Enable the transmission by setting bit TXEN,
87 // which will also set bit TXIF.
90 //6. If 9-bit transmission is selected, the ninth bit
91 // should be loaded in bit TX9D.
92 //7. Load data to the TXREG register (starts
100 /* set the breakpoint */
102 .direct "a", "\"PASSED\""