Demo-8    <<-BACK            HOME            UP --^           NEXT-->>  Demo-10
side4linux, a simple integrated development environment!

PCBS Demo-9  Communicate with the 'MC1' Machine Controller CPU board via the 'Bterm' program.


Purpose: 
Test the Machine Controller MC-1, Central Processing Unit's ability to communicate with the controlling computer.

Requirements:
Make sure that the latest help packages are installed.

Further Requirements:
Pre-Requisites:
Preamble:

This is the communication testing practical for the MC-1 CPU Board, it tests the Serial port of your computer and the MC-1 CPU using the Bterm communication program provided.


Step-1: Build the Hello Project and load it into the MC-1 CPU using the MC-1 Programmer.

As a first step in the Practical we are going to connect up all the cables used in Practical-8 and switch the computer on and then switch the power supply on. Check all your voltages are correct and switch off in reverse sequence. Now plug in the Serial cable from 'Serial Port-0' of the MC-1 CPU to an RS232C Serial Port of your computer (refer to Figure-0 below for the correct position for 'Serial-0'). Notice here that Serial-1 shares the PortE pins with the Programmer (Atmel did this not us!) so make sure always that Serial-1 has no cable plugged into it during programming on any occasion! You should have removed the pin from pin-1 (the square sided one ) of the male IDC ribbon cable socket and pushed it into the 10 pin female plug of the serial communication ribbon cable. By doing this first you are polarizing the plug and socket so that they cannot be plugged together the wrong way round. Do not be tempted to use polarized 10 pin sockets on the pcb as we will use a 22 ribbon cable plug when needing to use both serial communication ports.

MC-1 CPU Layout
Fig-0 MC-1 CPU Top Layout showing Serial Port - 0


Switch on your computer once the serial communication ribbon cable is plugged in. Your computer should be still operating normally!
Set your preferences to the Serial port you have used, either '0' for the first serial port or '1' for the second
with 'Preferences>IDE>Basic>ComPort'

Bring up the side4linux IDE on your computer and open the test project's 'hello.prf' file,  /SIDE/PRODUCTS/MC1/AVRA/Hello/hello.prf using 'Project>Open Project'  from the Main Menu as follows,

Open Project Hello
Fig-1 Open Hello Project Dialog


Now open the file 'hello.asm' using the 'Open-TXT' Toolbar button. You are now looking at a basic master assembly file for the Machine Controller modified for the 'Hello World' practical in this Demo. Click on the 'Build' button in the Toolbar and you should see the following in the Output Window below the open file.

Removing src/hello.hex
Removing src/hello.eep.hex
Building src/hello
AVRA: advanced AVR macro assembler Version 1.2.0 Build 30 (15. October 2006)
Copyright (C) 1998-2006. Check out README file for more info

   AVRA is an open source assembler for Atmel AVR microcontroller family
   It can be used as a replacement of 'AVRASM32.EXE' the original assembler
   shipped with AVR Studio. We do not guarantee full compatibility for avra.

   AVRA comes with NO WARRANTY, to the extent permitted by law.
   You may redistribute copies of avra under the terms
   of the GNU General Public License.
   For more information about these matters, see the files named COPYING.

Pass 1...
Pass 2...
done


Assembly complete with no errors.
Segment usage:
   Code      :       604 words (1208 bytes)
   Data      :         0 bytes
   EEPROM    :        28 bytes
Removed upload hex program Flash file from dbavrprog
Removed upload hex data EEprom file from dbavrprog
Copying Flash and EEprom hex files to dbavrprog

You have done more than just assemble the code, the IDE has also transferred your machine code program Flash file and your EEprom data file to the 'dbavrprog' serial programming program's 'files' directory ready for uploading to your MC-1 CPU. These files are 'upprog.hex' and 'upeeprom.hex', in 'Intel 8-bit Hex' file format. Note that if you were building your own board for an unrelated Product then the procedure will remain the same but we are concentrating only on the MC-1 for the rest of this Demo. OK, now that you have code to upload to your MC-1 CPU you will need to open the 'dbavrprog' program to program your AVR chip '. Launch the serial programming program as 'Tools>AVRA>AVR PROGRAM', you should be greeted by 'sudo's' password dialog similar to the graphic below,

 Sudo Dialog Box
Fig-2 Sudo Dialog Box.

After using your normal password that you signed on with and on clicking the Continue' button you should now have the dbavrprog screen up on your display as follows,


dbavrprog Sign On Screen
Fig-3 dbavrprog sign on screen.

Now to set up access to your printer port, click on the 'SetSerial' button and you should be greeted with the message,

I/O Permission granted

    Port Access Granted, you may continue!


Try the 'ReadID' button and see if you get the following message,

  Looking for signature bytes = : 1E :  97 :  02 : 

If you do not get the message or the ID bytes are wrong then close the programmer program and alter the IDE's global Delay timing value to a higher number.

  'Preferences>IDE>Basic>
Delay Value'

( 5 = OK for 1 Gigahertz machine, more for faster machines and less for slower ones! ),

Now if you can get this far click on the 'EraseALL' button then on the 'Test' button. This should turn up the following message,

Testing Flash Memory for Full Erasure!
Trying to Upload Intel Hex file files/upprog.hex to measure length!
Verify program Flash of length 004F0h bytes in progress!

Verify Program Address     0 = FFFF
Verify Program Address   100 = FFFF
Verify Program Address   200 = FFFF
Verify Program Address   300 = FFFF
Verify Program Address   400 = FFFF
Verify Program Address   500 = FFFF

 Trying to read 'EESAVE' Fuse on chip,  'EESAVE' flag = 0
 OK testing Flash Memory, I will now test EEprom Memory for Full Erasure.

Verify EEprom Address -->     0 = FF
Verify EEprom Address -->   100 = FF
Verify EEprom Address -->   200 = FF
Verify EEprom Address -->   300 = FF
Verify EEprom Address -->   400 = FF
Verify EEprom Address -->   500 = FF
Verify EEprom Address -->   600 = FF
Verify EEprom Address -->   700 = FF
Verify EEprom Address -->   800 = FF
Verify EEprom Address -->   900 = FF
Verify EEprom Address -->   A00 = FF
Verify EEprom Address -->   B00 = FF
Verify EEprom Address -->   C00 = FF
Verify EEprom Address -->   D00 = FF
Verify EEprom Address -->   E00 = FF
Verify EEprom Address -->   F00 = FF
Verify EEprom Address -->  1000 = FF

The Program and EEprom memory are erased!

Once you can complete 'Test' successfully you are ready to do some programming!
Click on the 'WriteFlash' button and get the following,

Attempting to write the program Flash Type-2

Uploading Intel Hex file files/upprog.hex to Program Flash memory

Writing Addr: 00000 Data|05C0|
Writing Addr: 00100 Data|002D|
Writing Addr: 00200 Data|0D91|

Writing Image to Program Flash
Writing Page: 0000
Writing program Flash Page:0 to chip
Verifying Page 00:80 Addr 00080
Writing Page: 0001
Writing program Flash Page:1 to chip
Verifying Page 01:80 Addr 00100
Writing Page: 0002
Writing program Flash Page:2 to chip
Verifying Page 02:80 Addr 00180
Writing Page: 0003
Writing program Flash Page:3 to chip
Verifying Page 03:80 Addr 00200
Writing Page: 0004
Writing program Flash Page:4 to chip
Verifying Page 04:80 Addr 00280

Write from file to Program Flash was successful

Notice that you must click on the 'EraseALL'  button then the 'Test' button and test the Flash for erasure before trying to program the Flash! The EEprom can be programmed at anytime but you must set the 'EESAVE' fuse yourself (unset by default) to prevent the 'EraseALL' button from erasing the EEprom along with the Flash. Also once the 'EESAVE' fuse is set then the 'Test' button only checks the Flash for erasure.

Step-2: Call up the command line version of 'bterm' to look for the 'sign-on message'.

Switch off the power supply. Close the programmer program and change workspace by clicking on the workspace switcher or right clicking on your Desktop. Change to the '/SIDE/TOOLS/SIDEtools/CLC/Bterm/src' directory and open a 'root' terminal there. For newcomers you can do this with Nautilus and the switch user 'su' command or as follows from a normal terminal e.g.,

if your user name was 'fred', from the Desktop's Main Menue where you call programs,

MainMenue>Accessories>Terminal

Maximise the Terminal and issue the 'su' command followed by pressing the 'Enter' key on your keyboard.
Enter your 'root' password
followed by pressing the 'Enter' key on your keyboard. ( watch the case of the characters, normally all in Lower Case!)
Issue the following command, 'cd /home/fred/
SIDE/TOOLS/SIDEtools/CLC/Bterm/src'. (alter to suit your user name and where you have put the 'SIDE' directory!)
You have changed to bterm's Project source directory and now issue the following command './bterm 0',  or './bterm 1' depending on the Computer's serial port you are using.
You should see the following on your screen (or similar!),

Attempting to Set Permissions
I/O Permission granted
Bterm GLASS TERMINAL PROGRAM Ver 1.3 (c) D. BURKE 17/7/1992 -> 2007
Commands available are,
    QR   <enter>    Toggle RESET line of MC-1 programmer to reset MC-1 CPU.

Displaying UART Registers

port --> 02F8   contents --> 10
port --> 02F9   contents --> 0
port --> 02FA   contents --> 1
port --> 02FB   contents --> 7
port --> 02FC   contents --> 1
port --> 02FD   contents --> 96
port --> 02FE   contents --> 0
scale reg low  -->   contents --> 12
scale reg high -->   contents --> 0

Notice the full stop and forward slash before the program name, this says to launch this program from the current folder and not some other program called bterm from the usual PATH.
  Also notice the space between the change directory 'cd' command and the forward slash that starts the target directory location. For other ways of using 'su' and 'sudo' re-read 'setup C build environment.txt'  and re-read Demo-8.

Step-3: Verify the Sign On Message and End.

Turn on the power supply and the following message should appear on the screen or similar!
( if not then try turning the power supply off then on again. If that does not work then issue a 'QR' reset command on the bterm terminal. )

MC-1 Ver 7.0 -  Hello World!

If you do not get the sign on message ( or it is corrupted ) then there are some reasons,
Congratulations if you have got this far as this is the end of Demo-9!


In Demo-10 We will start talking to the MC-1 CPU via the B2term program to check out the Serial Link.


We will provide other demos as 'side4linux' develops to cover integration into a real world machine controller.