Created Sat, 13 Aug 2011 18:05:35 +0000 by barry
Sat, 13 Aug 2011 18:05:35 +0000
Hello everybody,
i need help to set up a serial com,the peripheral have these following settings
8 bits / Parity even / 2 stop bits
also,how to set my uno32 board running at 80Mhz,or 72Mhz,16...
thanks for help ;)
Mon, 15 Aug 2011 08:32:20 +0000
also,how to set my uno32 board running at 80Mhz,or 72Mhz,16...
For clock setup, I have this piece of code. It works on Max32 but I don't see why wouldn't it work on uno32:
void SwitchClock() {
// First, switch to fast RC oscillator
SYSKEY = 0x0; // write invalid key to force lock
SYSKEY = 0xAA996655; // Write Key1 to SYSKEY
SYSKEY = 0x556699AA; // Write Key2 to SYSKEY
OSCConfig(OSC_FRC, 0, 0, 0); // set CPU clock to FRC
// input divider is magically remembered to be 2
#if F_CPU == 72000000L
OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_18, OSC_PLL_POST_1, 0);
#elif F_CPU == 96000000L
OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_24, OSC_PLL_POST_1, 0);
#elif F_CPU == 80000000L
OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_20, OSC_PLL_POST_1, 0);
#endif
__PIC32_pbClk = SYSTEMConfigPerformance(F_CPU);
SYSKEY = 0;
}
I guess you should call it from within setup(), although you can switch clocks all of the time. Consult the chip datasheet to find out how to set it up for different frequencies.
Wed, 17 Aug 2011 17:31:39 +0000
The C32 peripheral library function UARTSetLineControl can be used to set the UART properties.
UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_EVEN | UART_STOP_BITS_2)
Change UART2 to UART1, UART1A, etc. as appropriate.
You can get the documentation for the PIC32 Peripheral Library by downloading and installing the MPLAB IDE from the Microchip web site. On the Help menu, select Topics... and then select C32 Periperal Lib Guide.
Alternatively, you can write directly to the UART configuration registers. To get the documentation on this, download the PIC32MX3XX4XX or PIC32MX5XX6XX7XX Family Data sheet and the UART chapter of the PIC32 Family Reference Guide from the Microchip web site.
Gene Apperson Digilent
Sat, 20 Aug 2011 05:31:30 +0000
For clock setup, I have this piece of code. It works on Max32 but I don't see why wouldn't it work on uno32:
void SwitchClock() {
// First, switch to fast RC oscillator
SYSKEY = 0x0; // write invalid key to force lock
SYSKEY = 0xAA996655; // Write Key1 to SYSKEY
SYSKEY = 0x556699AA; // Write Key2 to SYSKEY
OSCConfig(OSC_FRC, 0, 0, 0); // set CPU clock to FRC
// input divider is magically remembered to be 2
#if F_CPU == 72000000L
OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_18, OSC_PLL_POST_1, 0);
#elif F_CPU == 96000000L
OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_24, OSC_PLL_POST_1, 0);
#elif F_CPU == 80000000L
OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_20, OSC_PLL_POST_1, 0);
#endif
__PIC32_pbClk = SYSTEMConfigPerformance(F_CPU);
SYSKEY = 0;
}
I guess you should call it from within setup(), although you can switch clocks all of the time. Consult the chip datasheet to find out how to set it up for different frequencies.
Thanks ;)
Sat, 20 Aug 2011 05:36:57 +0000
The C32 peripheral library function UARTSetLineControl can be used to set the UART properties. UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_EVEN | UART_STOP_BITS_2) Change UART2 to UART1, UART1A, etc. as appropriate. You can get the documentation for the PIC32 Peripheral Library by downloading and installing the MPLAB IDE from the Microchip web site. On the Help menu, select Topics... and then select C32 Periperal Lib Guide. Alternatively, you can write directly to the UART configuration registers. To get the documentation on this, download the PIC32MX3XX4XX or PIC32MX5XX6XX7XX Family Data sheet and the UART chapter of the PIC32 Family Reference Guide from the Microchip web site. Gene Apperson Digilent
Thank you gene! i guess that writing directly to configuration registers is the best way. ;)
Sat, 20 Aug 2011 16:14:00 +0000
I may not have been clear in my previous answer. The C32 peripheral library is available without having to download anything from the Microchip web site. It's included as part of the Microchip compiler runtime that is included in the MPIDE download. You just have to ensure the #include <plib.h> is in your source and then you can use any peripheral library functions. The download from the Microchip web site I suggested was just to get the documentation.
Personally, I would do it by writing directly to the registers. I already know how to do that and I don't have to learn a new library to do it.
Even better would be an enhancement to the serial object class to support this directly without the need to bypass the core abstraction layer. This is one of many ehancements I'd like to add to the system. Hopefully, we'll be able to address these things over the next few weeks (months?).
Let me know if you have any questions about programming the UART registers.
Gene Apperson Digilent