Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
BASCOM AVR, help reference (2007).PDF
Скачиваний:
294
Добавлен:
12.08.2013
Размер:
17.02 Mб
Скачать

© MCS Electronics, 1995-2007

button again to disable the Real hardware simulation.

When the program hangs it probably means that something went wrong with the serial

communication. The only way to escape is to press the Real hardware Simulation button again.

The Real Hardware Simulation is a cost effective way to test attached hardware.

The refresh variables button will refresh all variables during a run(F5). When you use the hardware simulator, the LEDS will only update their state when you have enabled this option. Note that using this option will slow down the simulation.

Watchdog Simulation

Most AVR chips have an internal Watchdog. This Watchdog timer is clocked from an internal oscillator. The frequency is approximately 1 MHz. Voltage and temperature variations can have an impact on the WD timer. It is not a very precise timer. So some tolerance is needed when you refresh/reset the WD-timer. The Simulator will warn you when a WD overflow will occur. But only when you have enabled the WD timer.

The status bar

The status bar shows the PC (program counter) and the number of cycles. You can reset the cycles by positioning the mouse cursor on the status bar and then right click. You will then get a pop up menu with the option to reset the cycles.

You can use this to determine how much time a program statement takes.

Do not jump to a conclusion too quick, the time shown might also depend on the value of a variable.

For example, with WAITMS var this might be obvious, but with the division of a value the time might vary too.

Program Send to Chip

Program send to chip shortcut , F4

This option will bring up the selected programmer window, or will program the chip directly if the 'Auto Flash' option is selected in the Programmer options section.

The following section applies to the Programmer window (programchip directly NOT selected) otherwise this is not shown to the user.

“Buffer” below refers to the buffer memory that holds data to be programmed to, or read from the chip.

Menu item

Description

File Exit

Return to editor

File, Test

With this option you can set the logic level to the LPT pins. This is

 

only intended for the Sample Electronics programmer.

Buffer Clear

Clears buffer

Buffer Load from file

Loads a file into the buffer

Buffer Save to file

Saves the buffer content to a file

Chip Identify

Identifies the chip

 

 

page -52-

 

© MCS Electronics, 1995-2007

 

 

 

Write buffer into chip

Programs the buffer into the chip ROM or EEPROM

 

Read chipcode into

Reads the code or data from the chips code memory or data

 

buffer

memory

 

Chip blank check

Checks if the chip is blank or erased

 

Chip erase

Erase the content of both the program memory and the data

 

 

memory

 

Chip verify

Verifies if the buffer is the same as the chip programor data

 

 

memory

 

Chip Set lock bits

Writes the selected lock bits LB1 and/or LB2. Only an erase will

 

 

reset the lock bits

 

Chip auto program

Erases the chip and programs the chip. After the programming is

 

 

completed, verification is performed.

 

 

 

 

The following window will be shown for most programmers:

Note that a chip must be ERASED before it can be programmed.

By default the FlashROM TAB is shown and the binary data is displayed.

When you have an EEPROM in your project, the EEPROM TAB will show this data too.

The most important TAB is in many cases the Lock & Fuse Bits TAB.

When you select it , the lock and fusebits will be read.

page -53-

© MCS Electronics, 1995-2007

These Lock and Fuse bits are different in almost every chip !

You can select new settings and write them to the chip. But be careful ! When you select a wrong oscillator option , you can not program the chip anymore without applying an external clock signal.

This is also the solution to communicate with the chip again : connect a clock pulse to the oscillator input. You could use an output from a working micro, or a clock generator or simple 555 chip circuit.

When you found the right settings, you can use$PROG to write the proper settings to new, unprogrammed chips. To get this setting you press the 'Write PRG' button.

After a new chip is programmed with $PROG, you should remark the line for safety and quicker programming.

Notice that the Write xxx buttons are disabled by default. Only after you have changed a lock or fusebit value, the corresponding button will be enabled. You must click this button in order to apply the new Lock or Fuse bit settings.

Many new chips have an internal oscillator. The default value is in most cases 8 MHz. But since in most cases the 'Divide by 8' option is also enabled, the oscillator value will be 1 Mhz. We suggest to change the 'Divide by 8' fusebit so you will have a speed of 8 Mhz.

In your program you can use $crystal = 8000000 then.

$crystal will only inform the compiler which oscillator speed you have selected. This is needed for a number of statements. $crystal will NOT set the speed of the oscillator itself.

Do not change the fusebit that will change the RESET to a port pin. Some chips have this option so you can use the reset pin as a normal port pin. While this is a great option it

page -54-

© MCS Electronics, 1995-2007

also means you can not program the chip anymore using the ISP.

Tools Terminal Emulator

With this option you can communicate via the RS-232 interface to the microcomputer. The following window will appear:

Information you type and information that the computer board sends are displayed in the same window.

Note that you must use the same baud rate on both sides of the transmission. If you compiled your program with the Compiler Settings at 4800 baud, you must also set the Communication Settings to 4800 baud.

The setting for the baud rate is also reported in the report file.

NOTE: The focus MUST be on this window in order to see any data (text, etc) sent from the processor. You will NOT see any data sent by the processor right after a reset. You must use an external hardware reset AFTER the terminal Emulator window is given focus in order

to see the data. Using the Reset shortcut, you will not be able to see any data because pressing the shortcut causes the Terminal emulator to lose focus. This is different than “HyperTerminal” which always receives data even when the Hyperterminal window does not have focus. Use Hyperterminal if you need to see the program output immediately after programming or reset.

File Upload

Uploads the current program from the processor chip in HEX format. This option is meant for loading the program into a monitor program for example. It will send the current compiled program HEX file to the serial port.

File Escape

page -55-