What is "reload program" ? Reset ? Re-flash ? What is "RUN" ? rchadwic wrote 2011-03-12 15:41: > I am trying to learn how to use the C18 V3 . 36 compiler to program an > 18F4550. Using PicKit3 and MPLab V8 . 46 . > I am trying to use the hardware USART functions to load a single characte= r > into the PIC and echo it back, repeating the character 30 times in a WHIL= E > loop. > The program is shown below. I am trying to declare constant hwi =3D 30. I= have > tried many ways of locating this, none are successful. > With the statement located at POSITION A, it does the WHILE loop once; to > repeat requires reloading the program. I am expecting the program to repe= at > each time I push RUN; it doesn't. > With the statement located at POSITION B, I get an OUT OF RANGE indicat= ion > 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 > syntax error that has not responded to typing error checks, research, and > checks 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. > However, I can not post this to that forum as I keep getting a message th= at > tells me I am using > "potentially harmful characters" A query to the forum yielded some > suggestions but no matter how I parse the post it fails. > > /********************************************************************** > /*This program loads an ascii "W" character into the PIC and repeats it 3= 0 > 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=3DOF= F, XINST=3DOFF, > LVP=3DOFF > > > char Txdata =3D 'W'; > int hwi=3D30; //POSITION A Loads OK, counts down and stops at 0 in > location 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 | > USART_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 nothing > I change (yet)=09 > > while(hwi>0) > =09 > { > WriteUSART(Txdata); // transmit the character > Delay10KTCYx (0); //Delay about half a second > hwi--; > } > > CloseUSART(); > while (1); // end of program > > } > > > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .