![]() ![]() While Spin is the original language of the Propeller chip, it is often more useful to use and teach C, as more people know C and it's more universal in the world of embedded systems. If it does, then ina will read a 1 for that pin, else it will read a 0. Likewise, when ina is accessed, the Propeller chip will read whether it sees a voltage or not. When outa is set to 0, it stops the current from flowing through that pin. Then, when outa is set to 1 for that pin, it sends a current through the circuit. Think about each pin as a switch: the dira register tells the Propeller chip whether it will be reading in some input value or outputting some current. These fundamentals are not as important once we go into the C code, but it is useful to understand what goes on behind the scenes. This is most likely a button or switch that simply closes a circuit. Finally, the ina register is used to read the input, either a 0 or 1, from a certain pin. The outa register is used to set the output state of a pin - either 0 (off) or 1 (on). The array index should be the pin number that is being assigned. The dira register is used to set whether a pin is input (0) or output (1). The most important registers are dira, outa, and ina. Thus, registers are incredibly important for the Propeller chip. ![]() This is an incredibly quick operation, as such it is perfect for manipulating hardware from microcontrollers. The registers on microcontrollers often have a more useful purpose for day to day programming: often times, one can set the state of a GPIO (general purpose input output) pin by directly changing a register's stored value. ![]() Sometimes, registers may contain special information: for example, the program counter contains the address of the current instruction. Registers are, in general, special hardware locations that are used to store small pieces of data, likely a memory address. This syntax is equivalent to dira := 0 or dira := 1 in Spin. Conversely, dira~~ is equivalent to setting the 0th bit equal to 1. For example, even in a high level interpreted language, register manipulation can be done with a simple array index: dira~ is equivalent to setting the 0th bit of the dira register equal to 0. Since Spin was made for the Propeller chip, the language has its own quirks in order to make programming the Propeller chip easier. The Propeller chip has two main languages which you may use: Spin, which is a high level interpreted language, or C, much like many other microcontrollers. This is incredibly rare in the microcontroller world - you almost never get a chip that has decent processing power (20 million instructions per second running machine code) on each of eight parallel processors. The Parallax Propeller chip is a very unique microcontroller - unlike most, who resort to interrupts and multi-threading for solutions, the propeller chip actually uses parallel processing. My goal is to teach how the Propeller chip achieves its goals within mechatronics. Also, I'm assuming for the sake of this tutorial that those reading it have some knowledge of programming. I will not cover any circuits or wiring that may occur as there are many tutorials for microcontrollers like Arduino which cover this material - it's exactly the same here. Note, I will only go into the semantics of how to program the Propeller chip and the fundamental knowledge behind it. Now, I want to appeal to those who already understand how to program. However, with microcontrollers being extremely useful for the projects I do in Gizmologists (a club at the University of Virginia). No one who attended had even seen C code outside of trivial examples. Recently, I taught a workshop on basic microcontrollers for those who have little to no experience programming. ![]()
0 Comments
Leave a Reply. |