Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UIT2_MovingAverage UIT2_AllpassReverb UIT2_CombReverb UIT2_FIR_LPF_Symmetry ... more
Diff: DAC_MCP4922.cpp
- Revision:
- 16:0001d3e93bee
- Parent:
- 14:6c60601c1834
- Child:
- 17:fd4f92ad4323
--- a/DAC_MCP4922.cpp Wed Dec 31 10:21:54 2014 +0000
+++ b/DAC_MCP4922.cpp Sun Jan 11 02:20:04 2015 +0000
@@ -1,7 +1,7 @@
//------------------------------------------------------
// Class for single DAC in MCP4922
//
-// 2014/12/21, Copyright (c) 2014 MIKAMI, Naoki
+// 2015/01/03, Copyright (c) 2015 MIKAMI, Naoki
//------------------------------------------------------
#include "DAC_MCP4922.hpp"
@@ -9,7 +9,7 @@
namespace Mikami
{
DAC_MCP4922::DAC_MCP4922(DAC dac, PinName mosi, PinName sclk,
- PinName cs, PinName ldac, int hz)
+ PinName cs, PinName ldac)
: wcr_(dac | 0x3000), spi_(mosi, NC, sclk),
ld_(ldac, 0), mySpi_((SPI_TypeDef*)NULL)
{
@@ -17,10 +17,16 @@
if ( (mosi == PB_15) || (mosi == PC_3) ) mySpi_ = SPI2;
if ( mosi == PC_12 ) mySpi_ = SPI3;
- // Set SPI format and bus frequency
+ // Set SPI format
spi_.format(16, 0);
- spi_.frequency(hz);
-
+ // Clock source of F401 for SPI1 : 84 MHz,
+ // SPI2, SPI3 : 42 MHz
+ mySpi_->CR1 = (mySpi_->CR1 & ~SPI_CR1_BR);
+ if (mySpi_ == SPI1) mySpi_->CR1 += SPI_CR1_BR_0;
+#ifdef __STM32F411xE_H
+ mySpi_->CR1 += SPI_CR1_BR_0;
+#endif // __STM32F411xE_H
+
// timer prescaler is set same value of boud rate for SPI
uint16_t psc = (2 << ((mySpi_->CR1 >> 3) & 0x07)) - 1;
ss_ = new Tim4_ss(psc, 18, cs);