|
LPC810 与 Labview 快递设计控制
[复制链接]
大多情况下Labview 与单片机间的通信大多数都是通过串口通信,但是要注意Labview 的串口通信是属于VISA模块,可惜LabView 默认情况下是不安装VISA驱动的,所以要手动安装驱动在官网的 资源与服务->NI Drivers -> NI VISA。
开始接触NI的时候,很多概念都比较低触,只能边学边用。
先做个控制灯的来练练先。
串口首先就是要做一个串口通信的调试
当能够正常接发数据的时间才开始修改成自己想要的内容,例如图上LED灯时就是有布尔开关转换来数组
程序柜架图如下:
LPC810 的关键代码如下
- int main(void)
- {
- SystemCoreClockUpdate();
- Board_Init();
- Init_UART_PinMux();
- Chip_UART_Init(LPC_USART0);
- Board_LED_Set(0, false);
- /* Allocate UART handle, setup UART parameters, and initialize UART
- clocking */
- setupUART();
-
- #if 0
- /* Transmit the welcome message and instructions using the
- putline function */
- putLineUART("LPC8XX USART API ROM polling Example\r\n");
- putLineUART("Enter a string, press enter (CR+LF) to echo it back:\r\n");
- /* Get a string for the UART and echo it back to the caller. Data is NOT
- echoed back via the UART using this function. */
- getLineUART(recv_buf, sizeof(recv_buf));
- recv_buf[sizeof(recv_buf) - 1] = '\0'; /* Safety */
- if (strlen(recv_buf) == (sizeof(recv_buf) - 1)) {
- putLineUART("**String was truncated, input data longer than "
- "receive buffer***\r\n");
- }
- putLineUART(recv_buf);
- /* Transmit the message for byte/character part of the exampel */
- putLineUART("\r\nByte receive with echo: "
- "Press a key to echo it back. Press ESC to exit\r");
- #endif
- putLineUART("Labview control LPC8XX Example\r\n");
- /* Endless loop until ESC key is pressed */
- recv_buf[0] = '\n';
- //while (recv_buf[0] != ESCKEY) {
- while (recv_buf[0] != ESCKEY) {
- /* Echo it back */
- LPC_UARTD_API->uart_put_char(uartHandle, recv_buf[0]);
- /* uart_get_char will block until a character is received */
- recv_buf[0] = LPC_UARTD_API->uart_get_char(uartHandle);
- switch (recv_buf[0])
- {
- case '0':
- Board_LED_Set(0, false);
- Board_LED_Set(1, false);
- break;
- case '1':
- Board_LED_Set(0, true);
- Board_LED_Set(1, false);
- break;
- case '2':
- Board_LED_Set(0, false);
- Board_LED_Set(1, true);
- break;
- case '3':
- Board_LED_Set(0, true);
- Board_LED_Set(1, true);
- break;
- default:
- break;
- }
- }
-
-
-
- /* Transmit the message for byte/character part of the exampel */
- putLineUART("\r\nESC key received, exiting\r\n");
- return 0;
- }
复制代码
Labview 程序
Labview Serial NI.rar
(22.82 KB, 下载次数: 17)
LPC810 的代码如下
uart_rom_polling.rar
(2.96 KB, 下载次数: 17)
|
赞赏
-
1
查看全部赞赏
-
|