Raspberry Pi OK LED 上的 SOS 莫尔斯电码 - 不工作 [英] SOS morse code on Raspberry Pi OK LED - not working

查看:29
本文介绍了Raspberry Pi OK LED 上的 SOS 莫尔斯电码 - 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 烘焙 Pi, 在 ARMv6 程序集中为 Raspberry Pi 构建一个非常基本的操作系统.我们已经从通过 GPIO 控制器打开 OK LED 到使用系统计时器使其闪​​烁,再到根据存储在 .int 值中的位图表示的模式使其闪烁.最后一个解决方案似乎不起作用.起初我以为我一定是错误地解决了问题,但无论我用功能性解决方案检查多少我的解决方案 此处提供,我看不出有什么显着差异.

I'm following Baking Pi, building a very basic operating system in ARMv6 assembly for the Raspberry Pi. We've gone from turning the OK LED on via the GPIO controller, to making it blink using the system timer, to making it blink according to a pattern represented by a bitmap stored in a .int value. This last solution doesn't appear to work. At first I thought I must have solved the problem incorrectly, but no matter how much I check my solution with the functional solution provided here, I can't see a significant difference.

我屈服了,最后下载了实际的解决方案,编译并安装在我的树莓派上.它表现出与我自己的解决方案相同的损坏行为.也就是说,LED 亮起,但一直亮着.我假设程序崩溃了,或者 and 指令没有按照导师的要求去做.

I caved and finally downloaded the actual solution, compiled it and installed it on my Pi. It exhibits the same broken behaviour as my own solution. That is, the LED turns on, but just stays on. I assume the program has crashed, or the and instruction isn't doing what the tutor wants it to do.

解决方法如下:

bitmap   .req r4
seq      .req r5
ldr bitmap,=pattern
ldr bitmap,[bitmap]
mov seq,#0         /* start at the zeroth bit */

loop$:
  mov r0,#16       /* set gpio pin 16: OK LED */
  mov r1,#1        /* bitmask starts with a 1 */
  lsl r1,seq       /* shift to the correct bit */
  and r1,bitmap    /* mask according to the pattern */
  bl SetGpio       /* set the LED state (r1 zero = off, non-zero = on) */
  bl Wait          /* wait for a short interval */
  add seq,#1       /* increment the sequence counter */
  and seq,#0b11111 /* reset seq to 0 if >= 32 */
  b loop$          /* loop forever */

.section .data

.align 2
pattern:
  .int 0b11111111101010100010001000101010

现在我知道 WaitSetGpio 功能可以正常工作,因为上一课只是按设定的时间间隔使 LED 灯闪烁,这是我通过 EORloop$ 的每次迭代中将 1 或 0 加 1.这里引入的唯一新的重要概念是表示 SOS 模式的位图.我对位图和位掩码很满意,因为我经常在高级语言中使用它们,所以我认为逻辑没问题,但还有其他问题,可能与 .int 的存储方式有关/填充?

Now I know the Wait and SetGpio functions work correctly, since the previous lesson just blinked the LED on and off at set intervals, which I was doing by EOR'ing a 1 or 0 with 1 on each iteration of loop$. The only new significant concept introduced here is the bitmap to represent the SOS pattern. I'm comfortable with bitmaps and bitmasks, as I use them regularly in higher level languages, so I think the logic is ok, but there's something else amiss, maybe with how the .int is being stored/padded?

上面的逻辑有什么问题吗?SetGpio 的合约是:

Does anything jump out as being wrong with the above logic? The contract of SetGpio is:

  • r0 必须设置为 GPIO 引脚编号,在本例中为 16
  • r1 必须设置为非零,如果 LED 应该打开,否则为零将其关闭
  • 返回值不重要

Wait 函数看起来像这样:

/* Sleep for 500 milliseconds */
Wait:
  push {lr}
  ldr r0,=500
  bl SleepForDelay
  pop {pc}

编辑 |实际上,我和导师的解决方案都是:

EDIT | Actually, the beavhiour in both mine and the tutor's solution is:

  1. LED 亮起一小段时间(我猜是一个点)
  2. LED 再次熄灭
  3. LED 亮起并一直亮着

我实际上认为第一次闪烁只是引导加载程序在运行,但如果我在程序的早期故意引入崩溃,LED 根本不会亮起.

I actually thought the first blink was just the bootloader operating, but if I introduce a deliberate crash early in my program, the LED never comes on at all.

推荐答案

原来这与代码无关,实际上是 Raspberry Pi 上的配置设置.

Turns out this had nothing to do with the code and was actually a configuration setting on the Raspberry Pi.

/config.txt 需要kernel_old=1.

/config.txt needed kernel_old=1.

这篇关于Raspberry Pi OK LED 上的 SOS 莫尔斯电码 - 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆