Thank you both for your help, as it happens it was a miss calculation for the baud rate, but your comments made me aware of a few things. Got it working fine, thanks again. Gavin On Nov 20, 2007 3:55 PM, Thomas C. Sefranek wrote: > There IS a 4:1 difference between BRGH and BRG16. > (High/ low speed baud rate generators) > You didn't say which you selected. > > * > | __O Thomas C. Sefranek WA1RHP@ARRL.NET > |_-\<,_ Amateur Radio Operator: WA1RHP > (*)/ (*) Bicycle mobile on 145.41MHz PL74.4 > > ARRL Instructor, Technical Specialist, VE Contact. > http://hamradio.cmcorp.com/inventory/Inventory.html > http://www.harvardrepeater.org > > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of > Gavin Dingley > Sent: Tuesday, November 20, 2007 9:14 AM > To: piclist@mit.edu > Subject: [PIC] PC RS232 Interfacing to a 18F458 - problems > > Hi, > I have only just started experimenting with PICs, and have > breadboarded a circuit using an 18F458. The function of the circuit is > to display on 8 LEDs the binary of the ACII character sent from a > PCs RS232 port (actually a virtual port from USB, i.e. one of those > USB to RS232 connector leads). > > First I loaded the SPBRG register with 0x0D, based of the formula > given in the datasheet: > > x = (Fosc / (BR * 64)) +1 > > Fosc is the instruction clock frequency (i.e. the crystal clock / 4), > BR is the desired baud rate, and x id the number to load into the > register, so: > > x = (920e3/(1200*64))+1 = 13 = 0x0D > > Using a 3.68MHz crystal > > Now when I tested the circuit is seemed to operate best at a baud rate > of 4800, rather than 1200, suggesting the frequency to use is not > Fosc, but the actual crystal frequency. > > The second problem is that the binary patterns displayed on the PIC > LEDs do not correspond to the ASCII of the typed character, and the > virtual terminal on the PC is set to 8-bit transmission. Also, > although the binary pattern is different for each character sent, even > if it is incorrect, then LED representing the MSB of the port is > always lit, regardless of the character sent. > > Now, either I still have the wrong baud rate, the character set used > by the PC is not ASCII, or there is something I have completely > missed. I don't think I am getting bit-rate and baud rate mixed-up > here either, the terminal sets baud rate, not bit rate, and the > datasheet I'm sure talks in terms of baud to. > > Thanks in advance, > > Gavin > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist