File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -135,9 +135,18 @@ class SPISettings {
135135 * at runtime (dynamically) and so we need to re-compute the proper
136136 * BRG value each time we start a transaction to be safe. */
137137 uint16_t GenerateBRG (void ) {
138- /* Compute the baud rate divider for this frequency.
138+ /* Compute the baud rate divider for this frequency. If the
139+ * desired clock rate is too slow for our slowest possible
140+ * on this system, use the slowest possible.
139141 */
140- return (uint16_t )((__PIC32_pbClk / (2 * DesiredSPIClockFrequency)) - 1 );
142+ if ((__PIC32_pbClk / (2 * DesiredSPIClockFrequency)) > 512 )
143+ {
144+ return (511 );
145+ }
146+ else
147+ {
148+ return (uint16_t )((__PIC32_pbClk / (2 * DesiredSPIClockFrequency)) - 1 );
149+ }
141150 }
142151 uint32_t con;
143152 uint16_t brg;
You can’t perform that action at this time.
0 commit comments