在线时间116 小时
UID3123257
注册时间2016-10-11
NXP金币0
TA的每日心情 | 奋斗 2017-1-18 20:00 |
---|
签到天数: 45 天 连续签到: 1 天 [LV.5]常住居民I
高级会员

- 积分
- 533
- 最后登录
- 2024-11-23
|
本帖最后由 云淡风轻1213 于 2017-4-8 17:26 编辑
板载仿真器和LPC54114的连接如图
仿真器和LPC54114之间连着串口,更新固件之后电脑就能显示出串口来,前面有帖子提到https://www.nxpic.org.cn/module/foru ... 1%E5%AD%A6%E4%B9%A0
但是这里注意一点,板子连着Jlink仿真器时识别不出来串口,需要把Jlink仿真器拔了。
在万利的工程上作修改
- #include "fsl_device_registers.h"
- #include "fsl_debug_console.h"
- #include "board.h"
- #include "pin_mux.h"
- #include "fsl_common.h"
- #include "fsl_iocon.h"
- #include <stdbool.h>
- #include "app_interrupt.h"
- #include "app_led.h"
- #include "app_adc.h"
- #include "app_key.h"
- #include "app_dmic.h"
- #include "app_spiflash.h"
- #include "app_pct2075.h"
- #include "app_wm8904.h"
- #include "app_usbdmsc.h"
- #include "ff.h"
- #include "diskio.h"
- #include "app_spisd.h"
- #include "fsl_usart.h"
- /*******************************************************************************
- * Definitions
- ******************************************************************************/
- /*******************************************************************************
- * Prototypes
- ******************************************************************************/
- volatile float fPCTValue;
- static FATFS g_fileSystem; /* File system object */
- const TCHAR driverNumberBuffer[3U] = {SDSPIDISK + '0', ':', '/'};
- //uint8_t LEDNUM[8]={0,1,2,3,4,5,6,7};
- /*********************************************************************************************************
- ** Function name: myDelay
- ** Descriptions: Èí¼þÑÓʱ
- ** input parameters: ÎÞ
- ** output parameters: ÎÞ
- ** Returned value: ÎÞ
- *********************************************************************************************************/
- void myDelay(uint32_t ulTime)
- {
- uint32_t i;
- i = 0;
- while (ulTime--) {
- for (i = 0; i < 5000; i++);
- }
- }
- /*******************************************************************************
- * Code
- ******************************************************************************/
- /*!
- * @brief Main function
- */
- int main(void)
- {
- char ch;
- uint16_t wADCValue = 0;
- uint8_t ret;
-
- /* Init board hardware. */
- /* attach 12 MHz clock to FLEXCOMM0 (debug console) */
- CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
- BOARD_InitPins();
- BOARD_BootClockRUN();
- BOARD_InitDebugConsole();
-
- SystemCoreClockUpdate();
-
- SysTick_Config(SystemCoreClock/1000);
-
- PRINTF("\r\n-------------------------------\r\n\r\n");
- PRINTF("hello world.\r\n");
- PRINTF("LPC54110 Sys Clock is %dMhz.\r\n", SystemCoreClock/1000000);
- PRINTF("\r\n-------------------------------\r\n");
-
- CLOCK_EnableClock(kCLOCK_InputMux);
- CLOCK_EnableClock(kCLOCK_Iocon);
- CLOCK_EnableClock(kCLOCK_Gpio0);
- CLOCK_EnableClock(kCLOCK_Gpio1);
-
-
- led_init();
- key_init();
- adc_init();
- dmic_init();
- ret = spiflash_init();
- if(ret == 1)
- {
- led_on(5);
- }
- else
- {
- led_off(5);
- }
-
- pct2075_i2c_init();
- wm8904_i2s_init();
- usbdmsc_init();
-
- if (f_mount(&g_fileSystem, driverNumberBuffer, 1))
- {
- PRINTF("Mount volume failed.\r\n");
- }
-
- #if (_FS_RPATH >= 2)
- if (f_chdrive((char const *)&driverNumberBuffer[0]))
- {
- PRINTF("Change drive failed.\r\n");
- return;
- }
- #endif
- FIL fd;
- if(f_open(&fd, "4:/readme.txt", FA_READ) )
- {
- PRINTF("f_open failed.\r\n");
- led_off(6);
- }
- else
- {
- led_on(6);
- }
-
- while (1)
- {
- // ADC test schedule
- wADCValue = adc_read(ADC_CHANNEL_NUM);
- wADCValue=wADCValue*3300/4096;
- PRINTF("ADC Value is +%d.%d mV.\r\n", (int)(wADCValue*100)/100, (int)(wADCValue*100)%100);
-
-
- }
- }
复制代码 LPC54114的ADC是12位的,基准电压是3.3V,所以计算实际测量电压公式为电压值=测量值*3300/4096;
通过串口将电压值打印出来。
旋转RV1电阻器,电压在不停的变化,电压范围0mv~3300mv,不过测量精度有几个mv的跳动。
USART打印ADC.rar
(5.36 MB, 下载次数: 98)
|
|