Go Down

Topic: Port manipulation (Read 1 time) previous topic - next topic


I'm assuming the __asm__(); is a function that sends data to the port?

no, __asm__ means "I'm using C(++) in this file, but insert this section of assembly language." Assembly language is much lower level language, where every lline corresponds to one thing the microcontroller does.

nop in assembly means "Don't do anything for one clock cycle." So it's a good way to get really really tiny delays (it's like a call to the theoretical delay(62.5 nanoseconds) if you're running an arduino uno. If you have another CPU or another clock speed, it willl be a different time.)


Hmmm thank you, that makes sense. destroys my only theory as to how this program outputs data (and more importantly, what sort of data I should be passing to this led strip)

I've done quite a few ventures into programming before but this sketch is really throwing me for a loop


The pin is being set using direct port manipulation. The register that contains the pin states for a given port is called PORTC. The DATA_1 and DATA_0 macros are diddling one pin in that port.


The line you want is:

PORTC |=  0X01;

The i/O ports are memory mapped - they act just like a memory location. "PORTC" is defined as a pointer to that location somewhere in the Arduino header files.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Go Up