root@ATmega328p> fcpuCPU Freq: 16000000

ckdiv2

ckdiv4

ckdiv8

ckdiv16

ckdiv32

ckdiv64

ckdiv128

ckdiv256



clock ckdiv2

Analog-to-Digital Converter (ADC). This peripheral is used when you have an analog sensor providing data (like temperature, light, acceleration, etc) and need to convert it to a digital value.

Serial Peripheral Interface (SPI). The SPI bus is used to communicate with other SPI-enabled devices, like external memories, LED drivers, external ADC's, etc. Parts of the SPI are used for ISP programming, or at least the pins are, so be careful when shutting this down if you are programming via ISP.

Two-Wire Interface. Some external devices use the I2C bus to communicate, although these are rapidly being replaced by SPI-enabled devices as SPI has a greater throughput.

USART. This is your serial interface. You probably don't want to turn this off if you are connected to the AVR via the serial connection! However, I added this in here as a skeleton for porting to devices that have multiple USART's like the ATmega162 or ATmega644P.

all. This argument to the powerup or powerdown command turns on all of the peripherals mentioned or turns them all off with one command. Again, use this command wisely.

root@ATmega328p> powerdown twiPowerdown of twi complete.root@ATmega328p> powerup twiPowerup of twi complete.

timer start

timer stop

root@ATmega328p> timer startStarted timer.root@ATmega328p> timer stopElapsed time: ~ 157 seconds

root@ATmega328p> passwd blahWrote root password to EEPROM

root@ATmega328p> passwd blinkyYou must authorize yourself first.root@ATmega328p> auth blahAuthorized.root@ATmega328p> passwd blinkyWrote NEW root password to EEPROM

print variablesUser-defined variables:Index Name -> Value(01): $FREE$ -> 0(02): $FREE$ -> 0(03): $FREE$ -> 0(04): $FREE$ -> 0(05): $FREE$ -> 0(06): $FREE$ -> 0(07): $FREE$ -> 0(08): $FREE$ -> 0(09): $FREE$ -> 0(10): $FREE$ -> 0(11): $FREE$ -> 0(12): $FREE$ -> 0(13): $FREE$ -> 0(14): $FREE$ -> 0(15): $FREE$ -> 0(16): $FREE$ -> 0(17): $FREE$ -> 0(18): $FREE$ -> 0(19): $FREE$ -> 0(20): $FREE$ -> 0Complete.

$newvar = 25$timeout = 23245

root@ATmega328p> echo $newvar$ newvar --> 25

User-defined variables:Index Name -> Value(01): newvar -> 25(02): timeout -> 23245(03): $FREE$ -> 0(04): $FREE$ -> 0(05): $FREE$ -> 0(06): $FREE$ -> 0(07): $FREE$ -> 0(08): $FREE$ -> 0(09): $FREE$ -> 0(10): $FREE$ -> 0(11): $FREE$ -> 0(12): $FREE$ -> 0(13): $FREE$ -> 0(14): $FREE$ -> 0(15): $FREE$ -> 0(16): $FREE$ -> 0(17): $FREE$ -> 0(18): $FREE$ -> 0(19): $FREE$ -> 0(20): $FREE$ -> 0Complete.

There are several other commands that the default command interpreter understands that you may find useful. You can see all the implemented and future-release commands by issuing help or menu at the prompt. I'll quickly cover them here as they are mostly self-explanatory.You can find out what your firmware has been configured to use as the CPU clock settings with the fcpu command:That's 16 million, or 16 million herz, more commonly known as 16 MHz. You can change this on the fly, for whatever reason, with the clock command. This command takes one argument: the prescaler to use when dividing your clock speed. The clock command understands these prescaler values:Using the command:when your cpu speed is 16MHz would result in your clock speed being changed to 8MHz. Using a prescaler of ckdiv64 with an initial clock speed of 16MHz will result in a final clock speed of 250 KHz. Why on Earth would you want to make your MCU slower? Well, for one, a lower clock speed consumes less power and if you have your MCU running off of a battery in a project enclosure you may not need it to run at top speed, and could therefore, lower the speed and reduce it's power consumption, increasing the battery life. Also, if you are using the clock for any sort of timing issues with another MCU, say, implementing a software UART or some such thing, you may want to set it to a particular value that is easy to get a nice even baud rate with lower error rates.On the same note as reducing power consumption mentioned earlier, you may want to further reduce power by shutting down some of the on-board peripherals that you are not using. The command interpreter and shell can currently power up and power down the following peripherals:The shell has a built-in 16-bit timer that is available for use. You start the timer with the timer command:and stop the timer with the stop argument:This timer will not conflict with the internal USART timer. See the code for the implementation details of the USART timer, if that sort of gory detail interests you.The shell can store an 8-character password into EEPROM. This password mechanism was created to support the telnet login capabilities, but could be expanded to protect other things. For example, you could require certain commands, like changing register values, through the authentication mechanism.Set the password with the password command:Authorize against he password (or require authorization programatically through the code) with the auth command. Note, that if you attempt to change the root password and there is already a root password set, you must authorize yourself against the old password before being allowed to change it to a new password.Of course, you will need to load the avrsh.eep file if you erase the firmware to have your old values and variables restored. The Makefile will create the EEPROM file for you.The shell understands the notion of user-defined variables. The code limits this to 20, but you can change that if you like by changing the define MAX_VARIABLES in script.h. You can save any 16-bit value (that is, any number up to 65,536) to a variable to be recalled later. The syntax is similar to registers except a dollar sign ($) is used to denote variables to the shell. List all your variables with the print variables command.Set a variable:Get the value of a given variable:You can see what all variables you've currently instantiated with the print command that you already know.The $FREE$ name just indicates that that variable location is free and has not been assigned a variable name yet.