I don't know about that compiler but perhaps an int is only 8 bits, check the warnings, it should mention something about an overflow. TTYL > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Harold M Hallikainen > Sent: Tuesday, April 23, 2002 12:38 > To: PICLIST@MITVMA.MIT.EDU > Subject: Constants in Microchip C > > > I'm messing around with the Microchip C compiler and > having trouble with > defining some constants to initialize the UART. Taking the formula I use > in assembly to set the BRG, I have tried the code below. I defined an > integer "debug" so I > could use a watch window to see what's going on. Stepping past the first > instruction (debug=ProcessorClock), it seems to work fine. debug ends up > with 0x14. Stepping past the second instruction, debug ends up with 0x00. > > What am I doing wrong? Since debug is an int, and an int > is a signed 16 > bits, it seems that this should fit fine. > Any ideas appreciated!!! > > Thanks! > > Harold > > > > // PIC UART Baud Rate > #define ProcessorClock 20; // Processor clock speed in MHz > #define BitRate 19200; // bits per second > int debug; // Something to watch as we debug > > > void main(){ > debug=ProcessorClock; > debug=19200; > IOinit(); // Initialize I/O > putrsUSART("Hello World!\r\n"); > CloseUSART(); > } > > void IOinit(){ > // Initialize all I/O > // Init on chip usart based on constants ProcessorClock and BitRate > OpenUSART(USART_TX_INT_OFF&USART_RX_INT_OFF&USART_ASYNCH_MODE&USART_EIGHT > _BIT&USART_CONT_RX&USART_BRGH_HIGH, (ProcessorClock*15625/BitRate)-1); > } > > > FCC Rules Online at http://hallikainen.com/FccRules > Lighting control for theatre and television at http://www.dovesystems.com > > > ________________________________________________________________ > GET INTERNET ACCESS FROM JUNO! > Juno offers FREE or PREMIUM Internet access for less! > Join Juno today! For your FREE software, visit: > http://dl.www.juno.com/get/web/. > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics