Is there anyone that has tried using the serial ports at different baud rates before? I’m trying to connect a gps to the TTL port and I’ve set the baud rate to 9600 but the setting is either ignored or overridden. Does anyone know what is going on? The code implies that you are able to change the baud rate yet every time I try it doesn’t change at all.
Can you establish communications with your PC at 9600 bps ???
You did look at \mcc18\h\usart.h header file and found USART_BRGH_LOW, but did you check the PIC 18F8520 manual to determine what the proper BAUD RATE for 9600 is?? I see it coded in …\VexCode_StartUp\PicSerialDrv.h as “baud_96 = 64, // Low speed”, but a little checking might be a good idea…
I see UART #1 being opened two places in the VexCode_StartUp, but UART #2 is only opened in PicSerialDrv.c on line 152.
I do see one anomaly… The BAUD RATE is set through an Enumeration, SERIAL_SPEED. There are Two Enumerations for SERIAL_SPEED… One in ifi_utilities.h, and one in PicSerialDrv.h, the one in PicSerialDrv.h has “baud_96”, the one in ifi_utilities.h does not.
I wonder if there is an issue with the value of “baud_96”. You might add “baud_96” to the Enumeration, SERIAL_SPEED in the Header File “ifi_utilities.h” to see if that might be the issue…
I am using hyperterminal to establish a connection at 9600 baud.
The baud rate did come out to the correct value according to the datasheet.
The discrepancy between the two enumerations did not make a difference, as long as it was defined somewhere.
You can add your own baud rates as long as you stick with the proper divisors to generate your numbers, for example I was able to establish a connection with the bot at 4800 baud which is not previously defined. The code for that was
I didn’t actually feel like adding to the enumeration (because i’m lazy like that) so i doubled the divisor to bring the baud down to 4800
I’ll post the divisors later, the numbers aren’t off the top of my head.
UART 1 is opened under the function Initialize_Serial_Comms. However, this function is only called from user routines.c which means that the two openings don't conflict. for the picserialdrv is meant to opperate with the ddt version of the project.
In conclusion, I was able to change the baud rates on both serial ports however, I don't have a reason why it didn't work before because i've tried the thing several times.