- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个项目,需要在 dsPIC 和 xbee 模块之间进行 UART 通信。当我运行已有的代码时,它会进行编译和编程,但不会通过 UART 线路发送任何内容。我只是想通过信号线发送一些东西,然后从那里开始处理。下面是我的主要代码以及 UART1.c,它们最初都是由 MCC 在 MPLABx 中创建的。提前谢谢大家。
#include "mcc_generated_files/system.h"
#include "mcc_generated_files/uart1.h"
#include "mcc_generated_files/pin_manager.h"
#include "mcc_generated_files/clock.h"
#include "mcc_generated_files/dma.h"
#include "mcc_generated_files/ecan1.h"
#include "mcc_generated_files/interrupt_manager.h"
#include "mcc_generated_files/mcc.h"
#include "mcc_generated_files/reset.h"
#include "mcc_generated_files/reset_types.h"
#include "mcc_generated_files/system_types.h"
#include "mcc_generated_files/traps.h"
#include "mcc_generated_files/watchdog.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
int count = 1, i;
char string[30];
int main (void)
{
UART1_Initialize();
while(1)
{
printf(string,"c"); //
for(i = 0;i<sizeof(string);i++)
{
UART1_Write(string[i]);
}
count = count + 1;
}
}
UART1.c
#include "uart1.h"
#include <stdbool.h>
#include <stdint.h>
/**
Section: UART1 APIs
*/
void UART1_Initialize(void)
{
/**
Set the UART1 module to the options selected in the user interface.
Make sure to set LAT bit corresponding to TxPin as high before UART
initialization
*/
// STSEL 1; IREN disabled; PDSEL 8N; UARTEN enabled; RTSMD disabled;
USIDL disabled; WAKE disabled; ABAUD disabled; LPBACK disabled; BRGH
enabled; URXINV disabled; UEN TX_RX;
// Data Bits = 8; Parity = None; Stop Bits = 1;
U1MODE = (0x8008 & ~(1<<15)); // disabling UARTEN bit
// UTXISEL0 TX_ONE_CHAR; UTXINV disabled; OERR NO_ERROR_cleared; URXISEL
RX_ONE_CHAR; UTXBRK COMPLETED; UTXEN disabled; ADDEN disabled;
U1STA = 0x00;
// BaudRate = 9600; Frequency = 40000000 Hz; BRG 1041;
U1BRG = 0x411;
U1MODEbits.UARTEN = 1; // enabling UARTEN bit
U1STAbits.UTXEN = 1;
}
uint8_t UART1_Read(void)
{
while(!(U1STAbits.URXDA == 1))
{
}
if ((U1STAbits.OERR == 1))
{
U1STAbits.OERR = 0;
}
return U1RXREG;
}
void UART1_Write(uint8_t txData)
{
while(U1STAbits.UTXBF == 1)
{
}
U1TXREG = txData; // Write the data byte to the USART.
}
uint16_t UART1_StatusGet (void)
{
return U1STA;
}
int __attribute__((__section__(".libc.write"))) write(int handle, void
*buffer, unsigned int len) {
int i;
while(U1STAbits.TRMT == 0);
for (i = len; i; --i)
{
while(U1STAbits.TRMT == 0);
U1TXREG = *(char*)buffer++;
}
return(len);
}
最佳答案
编辑:我忘记了 C zero-initializes global arrays ,这意味着您的 string
变量将仅包含 NULL 字符。
您对 printf 的调用看起来也很可疑:printf(string, "c");
。您正在尝试打印字符串并用“c”填充字符串中的第一个变量,但字符串从未初始化?
您如何知道没有发送任何内容,您是否有连接到 UART 引脚的逻辑分析仪?如果是这样,添加它可能会有用。
关于c - 尝试让 UART 在 dsPIC33EV256GM102 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55639948/
我正在尝试编写一个基本的 Greasemonkey 脚本,但我遇到了一些问题。本质上,该脚本将刷新页面并计算页面上的图像数量。如果图像数量增加,它会提醒我并激活该选项卡。如果图像数量相同或更少,它将以
我在 iPhone 5s(型号 A1530,iOS 8 build 12A365)上使用 Xcode 6 GM Seed(build 6A313)。我通过 USB 避雷线连接 iPhone。但在 Xc
当我为 iOS 运行 Today 扩展程序时出现此错误: dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from:
我使用 iOS 10 Beta 7 和 Xcode 8 beta 测试了我的应用,一切正常。然而,就在几分钟前,我安装了现在可用的 GM 版本,但遇到了一个奇怪的问题。 我在我的应用程序中使用自定义表
我正在尝试更新我们的 iPhone 应用程序以与 iOS 8 一起使用,但是当我使用 XCode 6 进行构建时,它会在编译 Storyboard时卡住并开始占用磁盘空间和内存 - 这种情况偶尔会发生
我正在使用 AVAssetWriter,它在 iOS6 上完美运行。 问题是,当我调用 finishWritingWithCompletionHandler ,完成处理程序不会在 iOS7 GM 上调
我有以下 Buffer 对象数组,这些对象是从由 jpg 和 png, ] 我正在尝试使用 Node.js 库 gm 将图像拼接在一起。 var currentGm = gm(images.
我的源数据如下所示: ab ab 我在上面运行以下命令: function lintPost(postText) { var replacements = { a : "4",
我正在尝试在 javax.mail 中使用 google 为 gmail 创建的 X-GM-EXT-1 IMAP 扩展。文档在这里https://developers.google.com/gmail
网页上有 function fn982734() { // some code } 在我的 Greasemonkey 脚本中,我有以下代码: var fn = fields[
这个问题在这里已经有了答案: Stop execution of Javascript function (client side) or tweak it (5 个答案) 关闭 9 年前。 我试图
我想将我的 iPad 更新到 iOS 4.2(我是注册开发者),但我想等到最终版本。 GM是最终版本,还是GM之后的最终版本进行了更改? 最佳答案 不一定。它们可以被制作,但大多数时候 GM 将是最终
我正在尝试获取图像网址,获取图像,然后将其写入文件系统,然后调整其大小。在调整大小结束时,我想将其返回到响应,以便客户端获取图像。现在 stdout.pipe(res) 没有返回,我收到 events
我正在努力解决我的脚本问题。无论我尝试做什么 GM.xmlHttpRequest 都会抛出错误“不是函数”。 我的其余代码工作正常。 这是我的代码的删节版: // ==UserScript== //
我是 xcode 和 ios 开发的新手。最近我看到了 xcode 版本,例如 xcode 6.0 通用 然后 xcode 6.0 .我想知道我们应该用GM做什么或者我们需要等到非GM发布才能构建io
以下代码创建内容为未定义的警报: // ==UserScript== // @name Unnamed Script 188765 // @version 1 // @grant GM
我从一开始就开始使用测试版(我已经安装了xcode 9和xcode 10 beta),今天我卸载了xcode9并安装了xcode10GM,但是当我的 Storyboard中有一个项目时,图形元素没有显
我使用 OS 10.10,Xcode 6 GM,我的项目由 swift(和 Objective-C)编写。 该项目可以使用Xcode 6-beta7运行。 Process:
我正在开发一个 iOS 应用程序,它在 Xcode 11.7 上运行良好,但是当我在 Xcode 12 中运行相同的代码并且当我进入 UIPageViewController 时,应用程序运行到无限循
我正在使用 gm对于带有 express.js 的 linux 服务器上的 node.js。它适用于小于 2MB 文件大小的图像。但是一旦超过,代码就会停止工作。这是代码 gm('public/'+a
我是一名优秀的程序员,十分优秀!