- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
以下函数 populateArpeggioArray 接受一个指向包含多个成员的 typedef 结构的指针,这些成员的身份不一定与我遇到的问题相关。在将指向结构的指针传递给函数 sortNoteStack 之前,populateArpeggioArray 应该对结构的内部元素执行一些操作。
我发现 sortNoteStack 从未对该结构进行操作,因为 populateArpeggioArray 在将更改后的值传递给 sortNoteStack 之前,有时会更改指向该结构的指针的值。
据我所知,代码的格式似乎正确,对结构元素执行的所有操作都使用了正确的指针解除引用。据我所知,没有一行代码能够修改指向结构的指针的值。使用 const 前缀声明结构没有帮助,因为它的成员因此也被锁定为固定值。
我认为这可能是模拟器的问题,而不是代码的问题,但如果我编写的代码存在一些潜在的问题,我当然想了解我的意思做错了。
感谢您的帮助。
-尼克
void populateArpeggioArray(arpeggio* arp) {
uint8_t i = 0,j=0, newNoteFlag=0;
for(i=0; i<12; i++) {
newNoteFlag = 0;
if(globals.keyboardCurrentState[i]) { /* Check to see if the current state shows that a keyboard button is pressed. */
arp->sequenceLength++; /* Temporarily increase the sequence length */
for(j=0;j < arp->sequenceLength;j++) { /* Check the pitch of each note currently in the note stack */
if(globals.keyboardNotes[i] == arp->notesUnordered[j].pitch) { /* If the currently selected note is already present in the note stack, */
arp->sequenceLength--;
newNoteFlag = 1; /* undo the temporary sequence length increase */
}
}
if(!newNoteFlag) {
arp->notesOrdered[arp->sequenceLength].pitch = globals.keyboardNotes[i]+liveArpeggio.transposeShift;
arp->notesUnordered[arp->sequenceLength].pitch = globals.keyboardNotes[i]+liveArpeggio.transposeShift; /* Add the new pitch to the appended note */
arp->notesOrdered[arp->sequenceLength].length = 111;
arp->notesUnordered[arp->sequenceLength].length = 111; /* Give the new note a default length. TEMP */
}
}
}
sortNoteStack(&arp);
}
最佳答案
使用sortNoteStack(&arp)
,您传递的是指针的地址,而不是结构的地址。你想传递结构的地址(指针的值)。因此,使用 sortNoteStack(arp)
。
关于c - AVR 模拟器中的意外指针重新分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18046648/
前言 众所周知,对于 16 位 I/O 寄存器(定时器计数器、ICR/OCR、ADC...)的原子和同时读/写高和低部分,AVR 使用影子临时寄存器。例如。在 ATmega8 上读取 TCNT1: u
我想使用 avr-gcc 将全局变量绑定(bind)到未使用的 I/O 寄存器(例如 PORTB),以减少代码大小。我在AVR的应用笔记AVR035中学到了这个技巧(第 14 页)。 在应用笔记中,他
我有一个项目,其中 ATtiny2313V 控制 7x5 LED 矩阵以显示滚动文本。为了显示文本,我构建了一个字体,它与程序的其余部分一起存储在闪存中。 整个程序,包括整个字体,占用 1106 字节
我尝试使用 this Code/Guide在 ATmega1284p 上。 我遇到的问题是链接器不工作,执行后出现以下错误消息(代码为 ATmega88 构建良好): avr-ld -o main.
我原以为 8 位 AVR 平台不需要任何对齐。但是,我在 an LLVM commit 中发现了以下评论: The previous data layout caused issues when de
我想生成一个具有可变频率和固定占空比 (50%) 的 PWM 信号。频率应在 0-25KHz 之间变化。这是用于 ATMEGA32U4 微 Controller 的,我正在使用 Atmel Studi
我想生成一个具有可变频率和固定占空比 (50%) 的 PWM 信号。频率应在 0-25KHz 之间变化。这是用于 ATMEGA32U4 微 Controller 的,我正在使用 Atmel Studi
当我尝试使用 AVR studio 4 调试一小段代码时,出现此错误: Build failed... No build tools defined. 有人能给我一些建议吗? 最佳答案 在 AVRSt
我有一个设置为 CodeVision AVR 项目的遗留代码。我想迁移到 AVR Studio 甚至更好的 NetBeans(使用 AVR 工具链或 WinAVR)。 有什么想法吗? 最佳答案 你应该
我在以 AVR 为目标的 C 中遇到毫秒延迟循环的问题。我在从 Ubuntu 存储库获得的 Linux 上使用 avr-gcc 4.7.0,我也有尝试了新编译的 4.7.2。目标硬件是 XMEGA12
如何启用或禁用 IDE 的自动完成功能 AVR-Studio 5或 AVR-Studio 4 ?我是否必须编辑一些安装文件才能做到这一点? 视频中AVR Studio 5: How to use th
我正在尝试用 Arduino Eclipse 插件替换 Arduino IDE。下载所需的一切并尝试编译最简单的“Hello World”程序后,我在 eclipse 中遇到以下错误: 调用时: wh
我继承了一个链接到一个库的应用程序,该库可能是用 gcc3 构建的。或者也许使用 imagecraft 编译器。这些信息现在已经消失在天堂般的位域中,我只剩下一个 libXXX.a 库来链接我的应用程
我正在尝试通过 USBASP 编程器将一些数据从 PC 发送到 ATmega328P 芯片。 它能够通过 SPI 传输最多 4 个字节。这 4 个字节可以在 USB Setup Packet 中设置(
我正在使用 ATMEGA128 与另一台设备进行通信。为此,我使用带有 ATMEGA128 的 SPI 作为从机。我使用 SS、SCK 和 MOSI 引脚。我面临的问题是,当我必须下载程序时,我必须断
我有以下汇编代码: __asm__ __volatile__ ( "1: subi %0, 1" "\n\t" "brne 1b" : "=d" (__count)
大家好! 我的 DIY 洒水器和鱼缸自动化的 AVR 取得了很好的进展,但我遇到了一个问题,这让我很烦恼。 哪个 if 语句在 AVR 上运行得更快?(在更少的时钟周期内)多少? if(temp_se
我见过的所有示例 AVR 程序都以如下代码开头: .org $0000 rjmp Reset ; ... Reset: ; Start of program 如果我不使用任何中
我正在使用avr-gcc 4.8.2对Atmel ATtiny13a微 Controller 进行编程。 这是我的C代码: #include #include int main(void) {
所以,我使用的是 ATMega168与 NerdKits使用两个中断 INT0 和 INT1 设置并连接一个 LCD。我想附上 Grove Heart Rate Monitor ,我已附加到 PCIN
我是一名优秀的程序员,十分优秀!