Pumpkin, Inc.

Pumpkin User Forums

uart baud rate

If you're having difficulty with Salvo's configuration options, post it here.

uart baud rate

Postby linkinpark32123 » Wed Apr 20, 2011 5:12 am

Where do you change the Uart baud rate in the sample code SD1. I know it is default set to 9600, the camera we are using 14400. I was looking in the Uart .c and .h files and I see where the comments says it defines the baud rate but I am unsure how it is actually doing it.

Thanks
linkinpark32123
 
Posts: 6
Joined: Thu Dec 16, 2010 11:12 am

Re: uart baud rate

Postby aek » Wed Apr 20, 2011 6:10 am

The way the UART code works is that the initializer fills the registers associated with the UART with the values required to achieve the desired settings.

The strings in uart.h are those register values.

Therefore, if one that you need isn't already defined in uart.h, you simply need to create (i.e. #define) a new set of symbols that do what you want. I suggest that you keep your symbol separate from those in uart.h, but send it in and I can incorporate it into a future release.
-------
aek
aek
 
Posts: 1862
Joined: Sat Aug 26, 2000 11:00 pm

Re: uart baud rate

Postby linkinpark32123 » Wed Apr 20, 2011 7:24 am

Yes I understand that. I cant find where the baud rate variables are defined that you use in the define statement UART_9600_N81_MAIN in dspic33_uart.h. I am looking in the dspic33_uart.h file and am looking at the uart_dis_abaud and believe this is the value that needs to change. I can not find anywhere where this is defined. Is it in the library file?

Thanks
linkinpark32123
 
Posts: 6
Joined: Thu Dec 16, 2010 11:12 am

Re: uart baud rate

Postby aek » Wed Apr 20, 2011 11:18 am

Any predefined values other than simple numercial constants are defined within the Microchip C30 header files associated with the libraries.

In the Microchip MPLAB C30 doc folder, there's a Windows help file that covers all of the PIC24 libraries. The dsPIC33 stuff is handled differently, in html files, IIRC.

IOW, Microchip defines all of those symbols.
-------
aek
aek
 
Posts: 1862
Joined: Sat Aug 26, 2000 11:00 pm

Re: uart baud rate

Postby yiqi » Wed Jan 30, 2013 4:42 am

Hi, I think the in define statement
#define UART_9600_N81_MAIN UART_RX_INT_EN & UART_RX_INT_PR7 & UART_TX_INT_DIS & UART_TX_INT_PR7, \
UART_EN & UART_IDLE_CON & UART_IrDA_DISABLE & UART_MODE_FLOW & UART_UEN_00 & UART_DIS_WAKE & \
UART_DIS_LOOPBACK & UART_DIS_ABAUD & UART_UXRX_IDLE_ONE & UART_BRGH_SIXTEEN & UART_NO_PAR_8BIT & \
UART_1STOPBIT, \
UART_INT_TX & UART_IrDA_POL_INV_ZERO & UART_SYNC_BREAK_DISABLED & UART_TX_ENABLE & \
UART_INT_RX_CHAR & UART_INT_RX_CHAR & UART_ADR_DETECT_DIS & UART_RX_OVERRUN_CLEAR, \
((MAIN_XTAL_FREQ/(32*9600L))-1)


9600 in the last line is the place you can change baud rate. Pls correct if I'm wrong :)
yiqi
 
Posts: 2
Joined: Fri Sep 28, 2012 5:06 am

Re: uart baud rate

Postby aek » Wed Jan 30, 2013 11:33 am

Yes, you are correct, but there are some assumptions as to how the clock is setup, and which prescalars are in force. Those (at least, in terms of the UART peripheral) are all controlled via that #define, so you should be able to get to a variety of baud rates simply via minor changes ...
-------
aek
aek
 
Posts: 1862
Joined: Sat Aug 26, 2000 11:00 pm


Return to Configuration

Who is online

Users browsing this forum: No registered users and 1 guest

cron