How To Read The Contents of Program Memory using AVR Assembler

A program which reads itself using the LPM instruction.

Why? What Do Instructions Look Like in the AVR Microcontroller

In the days of Commodore 8 bit computers, I created a little assembler/disassembler program.  So I was driven to know exactly what the instructions look like in memory, and exactly what gets stored in program memory when a program is uploaded to the microcontroller.

I suppose I’m thinking about trying to upload my own code my own way using my own assembler.

I’m using AVR Studio version 4.15 Build 623.  You can use Atmel Studio, but my computer was too slow for the newer version, and this old version really flies, has debugging, shows ports and registers too.

The Solution: The LPM Instruction

The code is in the description.  The secret sauce is the LPM instruction.  Here it is in the datasheet Instruction Set Summary:

The data sheet shows what happens during this LPM instruction:

Which means the contents at address Z get put into a register.  Then Address Z is incremented.  Here is the description:

How We Use the LPM Instruction

To use this, we must load register Z with address 0, the first location of our program on an Arduino chip.

To load register Z with an address, we can load its low byte and then its high byte.  Remember memory addresses are 2 bytes long, which is of course needed because there are so many of them.

The clr instruction is possible because we are setting both values to zero, it’s possible to use LDI but this seems more succinct.

The Main Loop to Read from Program Memory

Now there are two things to do, and they are in the following links:

1. AVR Asembler: Reading From Program Memory Using AVR Studio Debugger and Assembler

2. AVR Assembler: Comparing The Contents of Program Memory with the Hex Output File, and the Documentation.

Posted in Uncategorized | Leave a comment

Brokerage Fees, GST, Duties, Customs, Taxes to Canada

Shipping Raspberry PI from Hong Kong to Canada with no Brokerage Fees

NONE!  None whatsoever.  No hidden charges, no brokerage fees, no charges asked by the post office, no GST, nothing.

I bought my PI 2 from http://stores.ebay.ca/hundredpluscom and paid $57.43CDN, exactly as it says in ebay.ca (well it’s probably cheaper by now).  When I went to check out, there were no hidden charges, and my paypal amount was $57.43.

I ordered on February 1st and it arrived February 18th.  (17 days later).  It came to my front door from the Canada Post guy who asked for a signature, then handed over the parcel.  No brokerage fees, no GST, no duties, no nothing.

The envelope it came in was postmarked Germany (I don’t know why.   The store is in Hong Kong).  The Customs Declaration affixed to the back of the envelope read:

  • Merchandise
  • Raspberry Pi 2 – Model B. 1GB RAM.  Qty: 1   Value: 25
  • Total: .198lbs USD 25

I am not affiliated with this seller.  They don’t know I’m posting this.  I just wanted to share.

If you find this useful, share the luv, and give me a comment of thanks.🙂

 

Posted in Uncategorized | Leave a comment

Installing Arch Linux on Raspberry Pi 2

I installed Arch Linux on my new Raspberry Pi following these install instructions.

What to expect when the Raspberry PI 2 is booting

  • While trying to boot,  if no lights are blinking, it means the PI is not booting.
  • Red light is always on for power
  • Blinking green light twice then…
  • Alternating blinking of red and green light then…
  • Then network port lights go on and that’s a good sign!

Power Supply for Raspberry Pi 2

  • My charger is pretty much the same as many phone chargers
  • cable on charger has a USB large end and a USB small end.
  • Plug one end into the computer, the other into my PI.  Works fine.

My Problems with installing Arch Linux was a 32MB Sandisk

  • My 32GB Sandisk  attempt at booting was just showing a green light and a disturbing red light.
  • I found the lack of a light on the network port to be very peculiar
  • I expected a network light to be on regardless, as I often see a light on the Network card on my PC when it’s switched off.
  • But I was wrong.  The network light requires a system that is ALREADY BOOTED.
  • Also the DISTURBING RED LIGHT is supposed to ALWAYS BE ON,  as long as there is power.  It doesn’t matter if you haven’t booted yet, are booting, or have done booting, it’s always on.
  • The green light is SUPPOSED TO GO OFF once it is booted.
  • I replaced my 32 GB Sandisk with a 4 GB slower Sandisk, and followed Arch linux instructions (see first line of this posting), and it worked FIRST TIME!

Is this article useful?  Share some luv and leave a thanks for a comment🙂

 

Posted in Arch Linux, Raspberry Pi 2, Uncategorized | Tagged , | Leave a comment

TCNT1 Number must be positive and less than 64 solution

AVR Assembler Arduino

To store zero in TCNT1 using OUT won’t work.  To set the TCNT1 bits requires this technique.  First, you have to write to TCNT1H then TCNT1L but you can’t use OUT.  Here is the proper way to use assembly language to set TCNT1:

STS TCNT1H, 0x00
STS TCNT1L, 0x00

You, of course can also load those values into R16 then do

STS TCNT1H, R16
STS TCNT1L, R16

If you used this, send some luv and leave a reply!🙂

Posted in Uncategorized | Leave a comment

1400 hours, One seventh of the way to 10,000 hours of Piano practice

I’ve been counting.  And I track my hours every day.  On average, I have practice 160 minutes per day since I started. 

Today I exceeded 1400 hours, which is 1/7th the way to 10,000.

The computer forecasted that I will finish on January 1st, 2023.  (Yes that actual date, just by coincidence).

If that’s true, I will not even be 60 yet, far from it!  I may still have brain cells left.  ( I will be be just over 58)

Posted in Uncategorized | 1 Comment

The Power Supply of Behringer Xenyx 802 and Eurorack UB802, UB502, UB1002, 502, 1002

Here are the specs: USA/Canada model: 18.5VACX2 250mA.   Here are the pinouts with diagram and voltages.

My PSU measurements are in AC volts, there is a negligible voltage between the metal connector and any pin, and I checked for DC voltages in all combinations, and found none.  These are AC voltages!  Also note, that the power supply says something about a 3V 100 mA output, but there is absolutely no evidence of it.

ImageImage

My power supply came with my Xenyx802 and it is labeled “Eurorack power supply”.  I found that a bit odd.  Here are the other labels:

BEHRINGER
MODEL: MXUL3
ITEM NO: PSU-MX3-UL-01
INPUT: 120V~60Hz 14W
OUTPUT 1: 18.5V~ X2 250mA
OUTPUT 2: 3V~ 100mA
MADE IN CHINA

The voltages are :left pin to center pin: 20.7VAC
right pin to center pin: 20.7VAC
left pin to right pin: 41.9VAC
(no other measurable voltages anywhere).

I own both a Eurorack UB802 and a Behringer Xenyx 802, and the PSU which is pictured above, says on it MXUL3 (this is not a typo), is from the Xenyx 802, and works on either mixer.

Here is what the user manual to the Xenyx 802 says about the Power supply:

—————– >8  user manual start ——————

502/802/1002
Power consumption 13 W

USA/Canada
Adapter: Behringer PSU MX3UL (yes, this is not a typo)
mains voltage 120V~,60Hz

Europe/U.K/Australia
Adapter Behringer PSU MX3EU
Mains voltage 230V~, 50Hz.

—————– >8  user manual end ——————

Here are a few weird things I have noticed.

1. There really is no 3V rail that is used on the power supply

2. There are many variations of power supplies out there, some say 3V, others leave it off, some say 13W

3. With a Eurorack with no power supply, I have great interest in creating one.  One day I plugged an 18 Volt AC supply into two pins, and the Eurorack seemed to function.  My guess is the other two pins are for the phantom supply.  When I say “seemed to function”, it seemed to mix all channels to the main mix bus, with no problems, and no noticeable distortion.

3. I was tired of a mixer with only two pre-amps so I connected the two mixers together using only one power supply.  It was a simple matter of connecting the power supply line from one mixer’s preamp to the same place on the other mixer.  The reading on the first pre-amp was about 23 or 24 volts DC.  I used only two wires, one for positive, other for negative.  The funny thing is that the 2nd mixer works beautifully, and I tried ALL its functions, except phantom power, and the interesting thing is that the 2nd mixer’s heatsink was very very cool.  So my guess is that there is a circuit which creates the phantom power that accounts for almost all of the heat generated by these little mixers.  Just an interesting observation.

4. Noting item 4 above, my guess is a similarly connected 24 volt DC supply might possibly power one of these machines, and bypass all that circuitry that makes things hot.

5. If you read this, please leave a thanks, share the luv! 🙂

Posted in Uncategorized | 23 Comments

Enjoying What You Are Playing

I’m reading The Art of Practicing and one thing that struck me was that practicing should be enjoyable!  I thought it was work!  I’ve been practicing certain phrases with a very specific number of repeats hoping that it will sink in eventually.  I allocate my piano time and plan out each session with so many minutes.  But Bruser says that we rob ourselves of the beauty of the sound itself.  Get this:

The less pleasure we receive, the more we try to force the instrument; gripping it tightly instead of moving simply and comfortably.  This tension impedes the flow of musical vibration through the body.

This is so true.  So what I’ve done today and yesterday was concentrate less on the technical and more on just listening to the music.

Listen up:

Practicing is artful, creating something fresh and genuine.  We can practice being spontaneous rather than mechanical.  The spontaneity that marks a strong, communicative performance is actually cultivated during practice sessions.  The qualities of openness, uncertainty, freedom, and aliveness that characterize performing permeate practicing.

So I chose to hear the music.  To actually listen.  After all, I have to remember why I chose that piece in the first place.

Posted in Uncategorized | Leave a comment