在线时间1258 小时
UID3174487
注册时间2015-10-31
NXP金币2015
TA的每日心情 | 开心 2025-5-29 08:54 |
---|
签到天数: 2992 天 连续签到: 8 天 [LV.Master]伴坛终老
金牌会员
 
- 积分
- 12035
- 最后登录
- 2025-5-29
|
本帖最后由 limale 于 2017-4-27 21:00 编辑
上一篇帖子【LPC54114】+ B1.驱动ADS8332+官方库有bug解决了数据采样的问题,这两天又抽空把项目剩下的工作完善了一下。主要是实现了6轴力传感器的数据采集、串口wifi模块发送以及通过板载的数字麦克风进行简单的采样和停止采样的控制。原来的打算是通过语音进行控制的,开始考虑的有点儿简单,调试了两天还是有点儿问题只能等五一过后再搞了。
下来从硬件及软件方面做个总结吧。
1.硬件准备:
LPC54114板卡、I2C接口的oled、6轴力传感器、传感器采集电路、两块CC3200模块。
2.软件准备:
KEIL5.18、SDK2.0、串口工具等。
通过先前对这块板卡的学习,基本的准备工作都差不多了,其实这篇帖子也就是把这些功能组装起来。先来一张效果图吧。
简单的介绍一下,以LPC54114板卡为中心,I2C接口的OLED用于显示,右下角的CC3200模块配置成客户端通过串口连接LPC54114的串口5,右上角的CC3200模块配置成服务器通过USB转串口模块连接电脑。最左边的就是6轴的力传感器包括3轴的力和3轴的力矩,它的6对查分信号通过两级放大以后送到ADS8332进行AD转换然后通过SPI接口和LPC54114进行通讯。板载的数字麦克风进行声音的采集,目前完成的是通过对声音长短的分辨来进行采集的开始和停止。
下边是需要用到的一些IO口的配置:
连接OLED的I2C1接口
- i2c_master_config_t masterConfig;
-
- CLOCK_AttachClk(kFRO_HF_to_FLEXCOMM1);
- RESET_PeripheralReset(kFC1_RST_SHIFT_RSTn);
-
- IOCON_PinMuxSet(IOCON, 0, 23, 0x181);
- IOCON_PinMuxSet(IOCON, 0, 24, 0x181);
-
- I2C_MasterGetDefaultConfig(&masterConfig);
- masterConfig.baudRate_Bps = 100000U;
- masterConfig.enableMaster = 1;
- I2C_MasterInit(I2C1, &masterConfig, 12000000);
复制代码 连接ADS8332的SPI3接口,以及四个普通IO口(三个输出、一个输入)
- spi_master_config_t masterConfig = {0};
-
- /* attach 12 MHz clock to SPI3 */
- CLOCK_AttachClk(kFRO12M_to_FLEXCOMM3);
- /* reset FLEXCOMM for SPI */
- RESET_PeripheralReset(kFC3_RST_SHIFT_RSTn);
-
- /* SPI2 pins */
- IOCON_PinMuxSet(IOCON, 0, 14, (IOCON_FUNC2 | IOCON_MODE_PULLUP | IOCON_GPIO_MODE | IOCON_DIGITAL_EN)); /* SPI3_CS - FLASH */
- IOCON_PinMuxSet(IOCON, 0, 11, (IOCON_FUNC1 | IOCON_MODE_PULLUP | IOCON_GPIO_MODE | IOCON_DIGITAL_EN)); /* SPI3_SCK */
- IOCON_PinMuxSet(IOCON, 0, 12, (IOCON_FUNC1 | IOCON_MODE_PULLUP | IOCON_GPIO_MODE | IOCON_DIGITAL_EN)); /* SPI3_MOSI */
- IOCON_PinMuxSet(IOCON, 0, 13, (IOCON_FUNC1 | IOCON_MODE_PULLUP | IOCON_GPIO_MODE | IOCON_DIGITAL_EN)); /* SPI3_MISO */
-
- SPI_MasterGetDefaultConfig(&masterConfig);
- masterConfig.direction = kSPI_MsbFirst;
- masterConfig.polarity = kSPI_ClockPolarityActiveLow;
- masterConfig.phase = kSPI_ClockPhaseFirstEdge;
- masterConfig.baudRate_Bps = 1000000;
- masterConfig.sselNum = (spi_ssel_t)2; // use GPIO as CS is prefer
- SPI_MasterInit(SPI3, &masterConfig, CLOCK_GetFreq(kCLOCK_Flexcomm3));
-
- GPIO->DIR[1] &= ~(1U << ADS8332_EOC);
- #define ADS8332_EOC 3 //PIO1_3
- //
- #define ADS8332_CONVST_SET() led_on(0)
- #define ADS8332_CONVST_RESET() led_off(0)
- //
- #define ADS8332_RST_SET() led_on(1)
- #define ADS8332_RST_RESET() led_off(1)
- //
- #define ADS8332_INT() GPIO_ReadPinInput(GPIO, 1, 3)
- //
- #define ADS8332_CS_SET() led_on(2)
- #define ADS8332_CS_RESET() led_off(2)
复制代码 连接CC3200wifi模块的UART5
- #define DEMO_USART USART5
- #define DEMO_USART_CLK_SRC kCLOCK_Flexcomm5
- #define DEMO_USART_CLK_FREQ CLOCK_GetFreq(kCLOCK_Flexcomm5)
- #define IOCON_PIO_DIGITAL_EN 0x80u /*!< Enables digital function */
- #define IOCON_PIO_FUNC1 0x01u /*!< Selects pin function 1 */
- #define IOCON_PIO_INPFILT_OFF 0x0100u /*!< Input filter disabled */
- #define IOCON_PIO_INV_DI 0x00u /*!< Input function is not inverted */
- #define IOCON_PIO_MODE_INACT 0x00u /*!< No addition pin function */
- #define IOCON_PIO_OPENDRAIN_DI 0x00u /*!< Open drain is disabled */
- #define IOCON_PIO_SLEW_STANDARD 0x00u /*!< Standard mode, output slew rate control is enabled */
- #define PIN18_IDX 18u /*!< Pin number for pin 0 in a port 0 */
- #define PIN20_IDX 20u /*!< Pin number for pin 1 in a port 0 */
- #define PORT0_IDX 0u /*!< Port index */
- /* attach 12 MHz clock to FLEXCOMM0 (debug console) */
- CLOCK_AttachClk(kFRO12M_to_FLEXCOMM5);
- /* reset FLEXCOMM for USART */
- RESET_PeripheralReset(kFC5_RST_SHIFT_RSTn);
-
- CLOCK_EnableClock(kCLOCK_Iocon); /* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
- const uint32_t port0_pin18_config = (
- IOCON_PIO_FUNC1 | /* Pin is configured as FC0_RXD_SDA_MOSI */
- IOCON_PIO_MODE_INACT | /* No addition pin function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN18_IDX, port0_pin18_config); /* PORT0 PIN0 (coords: 31) is configured as FC0_RXD_SDA_MOSI */
- const uint32_t port0_pin20_config = (
- IOCON_PIO_FUNC1 | /* Pin is configured as FC0_TXD_SCL_MISO */
- IOCON_PIO_MODE_INACT | /* No addition pin function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN20_IDX, port0_pin20_config); /* PORT0 PIN1 (coords: 32) is configured as FC0_TXD_SCL_MISO */
-
- usart_config_t config;
-
- USART_GetDefaultConfig(&config);
-
- config.baudRate_Bps = 115200;
- config.enableTx = true;
- config.enableRx = true;
-
- USART_Init(DEMO_USART, &config, DEMO_USART_CLK_FREQ);
复制代码 还有数字麦克风和WM8904接口
- #define IOCON_PIO_DIGITAL_EN 0x80u /*!< Enables digital function */
- #define IOCON_PIO_FUNC1 0x01u /*!< Selects pin function 1 */
- #define IOCON_PIO_FUNC2 0x02u /*!< Selects pin function 2 */
- #define IOCON_PIO_FUNC4 0x04u /*!< Selects pin function 4 */
- #define IOCON_PIO_FUNC5 0x05u /*!< Selects pin function 5 */
- #define IOCON_PIO_INPFILT_OFF 0x0100u /*!< Input filter disabled */
- #define IOCON_PIO_INV_DI 0x00u /*!< Input function is not inverted */
- #define IOCON_PIO_MODE_INACT 0x00u /*!< No addition pin function */
- #define IOCON_PIO_MODE_PULLUP 0x10u /*!< Selects pull-up function */
- #define IOCON_PIO_OPENDRAIN_DI 0x00u /*!< Open drain is disabled */
- #define IOCON_PIO_SLEW_STANDARD 0x00u /*!< Standard mode, output slew rate control is enabled */
- #define PIN0_IDX 0u /*!< Pin number for pin 0 in a port 0 */
- #define PIN1_IDX 1u /*!< Pin number for pin 1 in a port 0 */
- #define PIN5_IDX 5u /*!< Pin number for pin 5 in a port 0 */
- #define PIN6_IDX 6u /*!< Pin number for pin 6 in a port 0 */
- #define PIN7_IDX 7u /*!< Pin number for pin 7 in a port 0 */
- #define PIN1_IDX 1u /*!< Pin number for pin 1 in a port 1 */
- #define PIN2_IDX 2u /*!< Pin number for pin 2 in a port 1 */
- #define PIN15_IDX 15u /*!< Pin number for pin 15 in a port 1 */
- #define PIN16_IDX 16u /*!< Pin number for pin 16 in a port 1 */
- #define PIN17_IDX 17u /*!< Pin number for pin 17 in a port 1 */
- #define PIN12_IDX 12u /*!< Pin number for pin 12 in a port 1 */
- #define PIN13_IDX 13u /*!< Pin number for pin 13 in a port 1 */
- #define PIN14_IDX 14u /*!< Pin number for pin 14 in a port 1 */
- #define PORT0_IDX 0u /*!< Port index */
- #define PORT1_IDX 1u /*!< Port index */
- //I2C³õʼ»¯
- const uint32_t port1_pin1_config = (
- IOCON_PIO_FUNC5 | /* Pin is configured as FC4_RTS_SCL_SSEL1 */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_MODE_PULLUP | /* Selects pull-up function */
- IOCON_PIO_INPFILT_OFF /* Input filter disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN1_IDX, port1_pin1_config); /* PORT0 PIN25 (coords: 3) is configured as FC4_RTS_SCL_SSEL1 */
- const uint32_t port1_pin2_config = (
- IOCON_PIO_FUNC5 | /* Pin is configured as FC4_RTS_SCL_SSEL1 */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_MODE_PULLUP | /* Selects pull-up function */
- IOCON_PIO_INPFILT_OFF /* Input filter disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN2_IDX, port1_pin2_config); /* PORT0 PIN26 (coords: 4) is configured as FC4_CTS_SDA_SSEL0 */
- //PDM0³õʼ»¯
- const uint32_t port1_pin15_config = (
- IOCON_PIO_FUNC1 | /* Pin is configured as PDM0_CLK */
- IOCON_PIO_MODE_PULLUP | /* Selects pull-up function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN15_IDX, port1_pin15_config); /* PORT0 PIN31 (coords: 13) is configured as PDM0_CLK */
- const uint32_t port1_pin16_config = (
- IOCON_PIO_FUNC1 | /* Pin is configured as PDM0_DATA */
- IOCON_PIO_MODE_PULLUP | /* Selects pull-up function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN16_IDX, port1_pin16_config); /* PORT1 PIN0 (coords: 14) is configured as PDM0_DATA */
- //MCLK
- const uint32_t port1_pin17_config = (
- IOCON_PIO_FUNC4 | /* Pin is configured as MCLK */
- IOCON_PIO_MODE_INACT | /* No addition pin function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN17_IDX, port1_pin17_config); /* PORT1 PIN17 (coords: 10) is configured as MCLK */
- //I2S_TX_DATA
- const uint32_t port1_pin13_config = (
- IOCON_PIO_FUNC4 | /* Pin is configured as FC6_RXD_SDA_MOSI_DATA */
- IOCON_PIO_MODE_PULLUP | /* Selects pull-up function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN13_IDX, port1_pin13_config); /* PORT0 PIN5 (coords: 39) is configured as FC6_RXD_SDA_MOSI_DATA */
- //I2S_TX_WS
- const uint32_t port1_pin14_config = (
- IOCON_PIO_FUNC4 | /* Pin is configured as FC6_TXD_SCL_MISO_WS */
- IOCON_PIO_MODE_PULLUP | /* Selects pull-up function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN14_IDX, port1_pin14_config); /* PORT0 PIN6 (coords: 40) is configured as FC6_TXD_SCL_MISO_WS */
- //I2S_TX_SCK
- const uint32_t port1_pin12_config = (
- IOCON_PIO_FUNC4 | /* Pin is configured as FC6_SCK */
- IOCON_PIO_MODE_PULLUP | /* Selects pull-up function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN12_IDX, port1_pin12_config); /* PORT0 PIN7 (coords: 41) is configured as FC6_SCK */
复制代码 复位以后串口0可以看到一下系统打印信息,串口5用于接口传感器数据。
此时程序正在等待中断的产生,当数字麦克风接收到声音的变化进入5次以上10次以下的中断会开始进行数据的采集。
当进入中断的次数大于10又归零而且小于5数据采集停止。
现在语音控制这块儿还是第一次搞,还没有完全弄懂。等五一节之后再好好研究一下吧。
CC3200模块的数据手册:
USR-C322_V2.8.pdf
(3.36 MB, 下载次数: 8)
|
|