--_002_AAAAAAAAAAAYAAAAAAAAAFeAPMmbRPNLt9qCAtIkuKHCgAAAEAAAAEZ_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I am trying to learn how to use the C18 V3 . 36 compiler to program an 18= F4550. Using PicKit3 and MPLab V8 . 46 . I am trying to use the hardware USART functions to load a single character = into the PIC and echo it back, repeating the character 30 times in a WHILE = loop. The program is shown below. I am trying to declare constant hwi =3D 30. I h= ave tried many ways of locating this, none are successful. With the statement located at POSITION A, it does the WHILE loop once; to r= epeat requires reloading the program. I am expecting the program to repeat = each time I push RUN; it doesn't. With the statement located at POSITION B, I get an OUT OF RANGE indicatio= n on the Watch window. A count of 30 was expected. Repeat requires reloadin= g the program. With the statement located at POSITION C, it will not compile and I get a s= yntax error that has not responded to typing error checks, research, and ch= ecks of the preceding line of code. The MPLAB supplied usart . c routine complies and runs correctly. I am doing something stupid that I cannot see. Can someone help me? My first thought regarding asking for help was the Microchip C18 forum. How= ever, I can not post this to that forum as I keep getting a message that te= lls me I am using "potentially harmful characters" A query to the forum yielded some suggesti= ons but no matter how I parse the post it fails. /********************************************************************** /*This program loads an ascii "W" character into the PIC and repeats it 30 = times. */ /*uses A CHARACTER*/ /* ADDITIONAL NOTES: /* Code uses the Peripheral support library available with MCC18 Compiler /* Code Tested on: /* Olimex demo board with 18F4550 processor /* The microcontroller uses an External Crystal (20 MHz). /* /* Uses TX pin for transmission and RX pin for reception. /* Baud rate of 9600 is configured for 20MHz oscillator frequency //**********************************************************************/ #define USE_OR_MASKS #include #include #include //-------------------------------Configuration setting --------------------= -------------------------- #pragma config FOSC=3D HS, PLLDIV =3D 5, FCMEN=3DON, WDT=3DOFF, IESO=3DOFF,= XINST=3DOFF, LVP=3DOFF char Txdata =3D 'W'; int hwi=3D30; //POSITION A Loads OK, counts down and stops at 0 in l= ocation 06B. Must //reload program to start again. #define BAUD_RATE_GEN 31 // Fosc =3D 20 MHz, Baud Rate =3D 9600 bps void main(void) { //int hwi=3D30; //POSITION B "Out of Scope" value shows on Watch window;= counts loops 30 //times and stops at 0 at address 201.Must reload program = to start again. OpenUSART(USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USA= RT_EIGHT_BIT | USART_CONT_RX | USART_BRGH_LOW, BAUD_RATE_GEN); baudUSART(BAUD_8_BIT_RATE | BAUD_AUTO_OFF); //int hwi =3D 30; //POSITION C Syntax Error that responds to nothi= ng I change (yet) while(hwi>0) { WriteUSART(Txdata); // transmit the character Delay10KTCYx (0); //Delay about half a second hwi--; } CloseUSART(); while (1); // end of program } --_002_AAAAAAAAAAAYAAAAAAAAAFeAPMmbRPNLt9qCAtIkuKHCgAAAEAAAAEZ_ Content-Type: text/plain; name="ATT00001.txt" Content-Description: ATT00001.txt Content-Disposition: attachment; filename="ATT00001.txt"; size=208; creation-date="Sat, 12 Mar 2011 06:46:24 GMT"; modification-date="Sat, 12 Mar 2011 06:46:24 GMT" Content-Transfer-Encoding: base64 LS0gDQpodHRwOi8vd3d3LnBpY2xpc3QuY29tIFBJQy9TWCBGQVEgJiBsaXN0IGFyY2hpdmUNClZp ZXcvY2hhbmdlIHlvdXIgbWVtYmVyc2hpcCBvcHRpb25zIGF0DQpodHRwOi8vbWFpbG1hbi5taXQu ZWR1L21haWxtYW4vbGlzdGluZm8vcGljbGlzdA0K --_002_AAAAAAAAAAAYAAAAAAAAAFeAPMmbRPNLt9qCAtIkuKHCgAAAEAAAAEZ_-- .