I am so happy that the scope still works. Pls thank the donor for me again!
You don’t need to follow the code, but for your edification its a pair of nested loops. The outer loop never ends (line 1), calling the inner loop which selects characters from the sequence “A-Z” (line 3) and sends them to the uart (line 6) with a small delay (line 10) between each character.
There is an arcane bit of code that quite honestly even I don’t understand now, that reverses the bits (I comment that line in, or out depending on the test I’m doing). Wrapped around the line that outputs the character, I have statements that turn on and off the LED1, which I use as a scope trigger – just as you taught me. (I am amzed I recall how to use the scope)
Here is the code which I have annotated. I’m sure you really do understand it.
- while (true) // never-ending outer loop
- {
- for (b=’A’; b<=’Z’; b++) // set ‘b’ to each of the asci characters in the range A-Z
- {
- nrf_gpio_pin_write(ERROR_PIN, 1); // turn on the LED as a scope trigger
- simple_uart_put(b); // emit the selected character in variable ‘b’
- // simple_uart_put(((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16);
- // to reverse bits I uncomment the line above, and comment out the one above it
- nrf_gpio_pin_write(ERROR_PIN, 0); // turn off the LED/trigger
- nrf_delay_us(1000*100); // a delay to make characters come out at 10Hz
- }
- }
No, the photo captions are not reversed. It seems like the data is. I am mystified.