问题标签 [xc8]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
1323 浏览

c - eeprom_write/read 函数导致编译错误(PIC 单片机)

我正在为 PIC 16f690 微控制器使用 MPLABX 和 C8 编译器。

通过阅读 C8 数据表,似乎 eeprom_write/read 函数包含在 xc.h 头文件中。但是,MPLAB 无法识别这些函数(无法解析标识符 eeprom_write/read),因此无法编译。使用 eeprom 是否需要其他初始化?

我试图存储的变量都是小于 1 字节的无符号字符。断章取意,这就是它们的格式(“final”是先前声明的字符):

0 投票
2 回答
6391 浏览

c - Receiving "undefined symbols" error with XC8 concerning plib I2C functions

Hey there StackOverflow!

My question concerns errors being reporting within the program pasted (far) below. The target device is the PIC12LF1552, it has one serial peripheral on it that I assumed could be used in conjunction with the library supplied with Microchip's XC8 compiler. Some sources on the internet have said that only higher end devices in the PIC18 line would support the library functions, other sources have said the library functions work just fine. So I decided that I didn't want to rewrite the I2C functions from scratch, nor did I want to write any amount of assembly for this project. Thus I settled on using the provided peripheral library that comes with XC8. I read up on the compiler documentation for how to source them (as seen in i2c.h below). I know theres some error checking to do on those commands as per the documentation and some examples I've seen, but for the time being I'm assuming that both the master and the slave will behave perfectly just so I can get this thing off the ground.

I have included all relevant paths, which is why I assume it gets this far in the compilation process. My level of knowledge when it comes to the inner workings of a C language and compiler is very limited, I only know how to use these tools at a basic level, so there might be something fundamental I'm missing here.

Anyways, when I compile this code in MPLABX v1.95, I get this:

:0: error: undefined symbols: _AckI2C(dist/pickit3/production\strobe.X.production.obj) _ReadI2C(dist/pickit3/production\strobe.X.production.obj) _IdleI2C(dist/pickit3/production\strobe.X.production.obj) _OpenI2C(dist/pickit3/production\strobe.X.production.obj) _StopI2C(dist/pickit3/production\strobe.X.production.obj) _NotAckI2C(dist/pickit3/production\strobe.X.production.obj) _WriteI2C(dist/pickit3/production\strobe.X.production.obj) _StartI2C(dist/pickit3/production\strobe.X.production.obj)

I couldn't find anything relevant on Google, StackOverflow, or otherwise concerning this problem from my specific context (another guy had a very similar issue when porting from Microchip's legacy C18 compiler, but I already did everything that guy did to solve his problem).

So I guess, the question is, why am I getting this compiler error, and what is the mechanism behind it in the C language or Microchip's implementation of it that is causing this?

0 投票
1 回答
206 浏览

c - 正确关闭 PIC12F675 上的 ADC

我正在尝试将一些简单的数字 IO 代码从 CCS 编译器移植到 XC8。

单片机是PIC12F675。

XC8 没有 12 系列的外设库。

我已经设法配置它,设置时钟等。

默认情况下,我似乎无法将引脚 0-3 用作数字 IO。

我认为这是因为 ADC 配置,但它可能是以下任何参数。

有人可以帮我把这个 CCS 代码写到 XC8 上吗?

提前致谢。

0 投票
2 回答
2581 浏览

c18 - Microchip XC8 和 C18 编译器有什么区别?

我想进一步了解 XC8 和 C18 编译器之间的区别。

我知道 XC8 是所有 8 位微芯片控制器的最新编译器。例如 PIC16F、PIC18F。C18 是他们 PIC18 产品的编译器。对于C18,PIC18系列包括PIC18F和PIC18C,是吗?

我看到 XC8 是比 C18 更进一步的版本。是不是意味着XC8也可以编译C18之前编译的全部/部分代码。如果不是,应该是什么。

顺便说一句,目前(几天)我正在寻找有关 PIC18F2455/2550/4550 USB 接口的示例/教程代码。如果您有任何指示,他们将不胜感激。

0 投票
1 回答
351 浏览

c - 使用 USART2 连接两个 PIC18F 入门工具包

我想使用 RS232 连接两个 PIC18F 入门套件(带有 PIC18F46J50)。由于 USART1 已经连接到读卡器(集成),我需要使用 USART2(我需要将 RX2/TX2 重新映射到 RP19/RP20 引脚-RD2/RD3)。

我已经找到了一些发送的演示代码:

我使用两条线(在 D2 和 D3 引脚上)连接了两块板,我想将一个字符串从 board1 发送到 board2。我想我需要使用中断来读取,但我还没有找到任何演示代码。另外,我不知道配置引脚是否正常。有人可以告诉我如何接收发送到板 2 的文本吗?

0 投票
1 回答
3120 浏览

c - 未指定芯片名称;使用“PICC18 --CHIPINFO”

我做了一个简单的程序来点亮一个 LED。

我使用 PIC18F46k22 和 XC8 编译器。问题是当我编译程序时,编译器给出的消息没有指定芯片名称;使用“PICC18 --CHIPINFO”

你知道问题出在哪里吗?

0 投票
3 回答
198 浏览

c - mplab xc8/16 builtin_constant_p

我在 mplab 编译器用户指南中搜索此内容,但没有找到任何内容。我在这里要求它确认我不是盲人或任何东西:

GCC 编译器提供了一些非常有趣和有用的内置函数,例如 __builtin_constant_p(x) 或类似的东西。我从未在微芯片编译器中发现过类似的东西,而且我认为没有。

那么问题来了:Microchip XCxx 编译器是否提供除特定于设备的函数之外的任何非标准内置函数(例如在给定寄存器地址声明变量或声明中断函数)?

编辑:澄清更多:我最感兴趣的是从编译器中检索信息。一个很好的例子是类似 builtin_constant 的东西,因为它使程序可以使用通常不可用的信息。但我不将这个问题限制为仅查找常量表达式。

0 投票
2 回答
191 浏览

c - 按位运算 !x 和 x==0

我只是想问一个问题。

!x一样的x==0吗?

我正在使用这些来测试一个条件(中断),在这种情况下x只有一个位。我使用它的代码示例:

0 投票
4 回答
441 浏览

c - 将数组值的字符数组转换为指针数组

我需要将数组聊天值数组放入指针数组中。首先,我使用了这样的代码,它对我有用。

所以我可以通过 index 访问该值current_tag_lists[0]

但我的实际要求是在运行时添加这些值,如下所示。这是一个示例代码。

但问题是“current_tag_lists”不存储所有值。它只存储当前值。它每次都替换以前的值。我需要将值保留为我上面的示例,并且需要从索引(current_tag_lists [0])访问。

谁能帮帮我吗。这是我的实际代码。

请只看 if(a==13)。

这是我的错误日志。

0 投票
2 回答
1103 浏览

c - PIC16F887 PORT 不适用于 XC8 C 编译器

我对 PIC 编程很陌生,我正在尝试使用 C(在 MPLABX 中使用 Microchip 的 XC8 Free编译)来制作一个简单的“输入到输出”程序。
我遇到的问题是 RA2、RA3 和 RA5 输入引脚在用 C 编程时无法正常工作。
这可能不是硬件问题,因为在梯形图编程时这些引脚工作正常。
我在互联网上搜索了一段时间,还没有找到有同样问题的人。

我正在尝试刻录到 PIC 上的程序如下:

如果我将 RA4 设置为 HIGH,我会在 PORTB 上得到输出,但对于 RA2、RA3 或 RA5 则没有。我相信这可能是配置位或其他问题,但我不确定。

正在使用的硬件:

  • 微芯片 PIC16F887

  • FLEXiS Plus Board(抱歉没有英文手册,但在第 8 页和第 9 页有电路板原理图)

正在使用的软件: