Thursday, January 21, 2010

PICMe EVB Kit

PICMe Evaluation Board(ASTI-DOST Copyright-2008)


Objectives:
1) To Familiarize with the use of PICMe
2) To be able to use PICMe in Microcontroller embedded applications
2) To post a support of using PICMe EVB.


Introductions:

PICMe™ OVERVIEW

A)Product Features:

The PICMe™ Microcontroller Starter Kit is designed to give electronic enthusiasts an initial application material in their prototyping and laboratory needs. The board supports the PIC16F877A in the 40-pin DIP package. These controllers have a program memory built on Flash technology which provides fast erasing and reprogramming, thus allowing a quick debugging or error checking. The PICMe™ Microcontroller Starter Kit has the following main features:

Powerful MCU
10-bit, 8-channel Analog-to-Digital (A/D) Converter. Synchronous Serial Port (SSP) with SPI™ (Master mode) and I2C™ (Master/Slave mode) Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address Up to 8K x 14 words of Flash Program Memory, up to 368 x 8 bytes of Data Memory (RAM), up to 256 x 8 bytes of EEPROM Data Memory Has 33 input/output (I/O) pins. Pocket Size

The PICMe™ Microcontroller board has a compact size of 3.7” x 1.65” that includes all the electronic components used Dual Function Header. The I/O pins can be accessed easily via the dual function headers, which can act as sockets or pins that can be mounted on a breadboard or on any prototyping board.

Ease of Reprogramming
No external programmer is required for the boot loader. The PICMe™ Microcontroller Starter Kit has a pre-installed PIC boot loader located in the PIC's memory area. The PIC boot loader initializes the system to enable reprogramming of PIC microcontrollers without the need for a chip programmer, a device used to transfer the compiled program from the computer into the microcontroller memory. It utilizes the self-programming features of the PIC microcontroller, which allows in-circuit reprogramming and downloading of codes.

B)Package contents:

The PICMe™ Microcontroller Starter Kit should contain the following materials:
a. PICMe™ Microcontroller Board with PIC16F877A Microcontroller
b. CD containing the software tools, sample program codes and support documentations
c. Serial cable (RS-232 data cable)
d. AC-DC power supply adapter (optional)
e. Portable case

C)Board Layout:

D)Components & Descriptions:
PIC16F877A Has up to 8Kx14 words of In-System Programmable Flash memory with up to 256x8 bytes of EEPROM and up to 368x8 bytes of Internal RAM
RJ11 Serial Input Interfaced on board through a RS232 driver/receiver pin-compatible level converter chip. Flash PIC microcontroller units like the one in the development kit can be programmed by connecting it to RS232 in the appropriate COM port of the computer and using the provided boot loader application.
DC power jack (J2) Used to connected to the power adapter and interfaced with an on-board regulator
Power Regulator (U3) Allows power inputs from 100-240V to an output of 12V (1.0A) towards the board
Red LED (D10) Connected to the power regulator, which indicates if the power is on
Potentiometer (POT) A 5k trimmer resistor to control an analog signal input interfaced on thPin 2 (PIN A0) of the PIC6F877A
microchip.
Reset Switch Attached to the Master Clear/Reset Input or Pin 1 of the PIC microcontroller
Push-Button Switch 1 (SW1)Connected to Pin 32 (PIN B0) of the microcontroller and used for handling interrupts
Push-Button Switch 2(SW2) Connected to Pin 8 (PIN E0) of the microcontroller and used for making control inputs
Jumper Header (J3) If the header is shorted or the Jumper is inserted, then the PIC microcontroller can output signals to the yellow LEDs. Otherwise, Port D is open as parallel slave port for external interfacing.
2-Pin Header (J4) Provided by the power regulator with +5V DC output at 250mA and GND
6-Pin Header (Port A) A bidirectional I/O port connected to Pin 2 (PIN A0) to Pin 7 (PIN A5) of the microcontroller. PIN A0 is an analog input interfaced with the potentiometer While the other pins can be interfaced with other analog inputs and as well with clock/timer.
8-Pin Header (Port B) A bidirectional I/O port connected to Pin 33 (PIN B0) to Pin 40 (PIN B7) of the microcontroller. PIN B0 is connected to Push-button Switch 1 (SW1) to test its capability to handle interrupts. While the rest of the pins can be accessed as interrupt-on-change pins or in-circuit debugger pins.
8-Pin Header (Port C) A bi-directional port connected from Pins 15,16,17,18, 23 and 24 (PIN C0 to PIN C5) of the microcontroller respectively. Pin 25 (PIN C6) and Pin 26 (PIN C7) are used for USART Asynchronous Transmit and Receive respectively. These two pins are currently dedicated and set-up for the Starter Kit and Computer serial communication such as the downloader and HyperTeminal.
8-Pin Header (Port D)Also a bidirectional port interfaced to the 8 yellow LEDs and a jumper header. This port is either used for outputting values on the LEDs or as parallel slave port.
3-Pin Header (Port E) Pin 8 (PIN E0) is connected to Push-button Switch 2 (SW2) which “read” control inputs, while Pin 9 (PIN
E1) and Pin 10 (PIN E2) are defined as “control” and “select” controls. These three pins can also beused as parallel slave port or analog inputs.
8 Yellow LEDs All of which are I/O controlled by Port D and are jumper selectable
XTAL A 20 MHz crystal located on the clock socket under the PIC16F877A microchip and is used as the external clock of the microcontroller
100 Mils (0.1”) centered headers Provide a more accessible or simple connection to the processor special function pins and I/O
ICD2 Pins for In Circuit Debugger


GETTING STARTED

A)Hardware Setup:



B)Using PICMe™ DSM:
The PICMe™ DSM (Downloader and Serial Monitor) is a software program that can be used to easily download the code compiled in the PIC Compiler directly into the MCU and also serves as a communication tool between the MCU and PC.
System Installation
• Look for the folder PICDSM Setup and copy it from the CD onto your PC.
• Click setup icon and this will display the PICMe™ DSM window.



C)Using PIC Downloader:

1. Run the program PICDSM.exe. Select the Downloader tab.

2. Locate the desired HEX file through the Browse button.

3. Set the Port number. The default setting of the Port is COM1.

4. Set the Baud Rate to 57600.

5. Click the Download button to start downloading the file. Click Cancel button if you want to
stop the activity.



D)Using the PICMe™ Serial Monitor:

1. Run the program PICDSMv1.exe. Select the Serial Monitor tab.



2. Set the correct Port settings before attempting to connect with the serial communication port of the device. The default setting of the Port is COM1. Set the Baud Rate at which data is being sent. The baud rate setting of the Serial Monitor must match the baud bate setting of the device which is set by the program. Set the Parity, Data Bits, Stop Bits, and Handshaking method accordingly to match the requirements of the device. The default values are none, 8,1 and none respectively.

3. Click the Connect/Disconnect button to connect/disconnect to the device.



4. In the Receive area, check the desired format (ASCII or HEX format) of the received data.
The Clear button is used to clear the window.

5. In the Transmit area, enter the specific data to be sent. Check the As HEX tab when
sending HEX-formatted data.

6. Click the Send button to transmit the data to the microcontroller.




USING CCS COMPILER

1. Run the compiler by opening pcw.exe.

2. Create a new file and save it as blinker.c.




3. Enter the C program below onto the source code template window.(CCS Sample
Program)




4. Run the program: Compile->Build
All -> Compile

5. Locate for the blinker.hex




CCS SAMPLE PROGRAM

D)LED SWITCH ON & OFF

#include <16f877a.h> //Initialization
#include
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use delay (clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void
main()

{ //Start of Main Program
int8 a=0x00; //Set variable a to 0

delay_ms(500);
printf ("\nIf you can read this message,");
printf (" you are using the PICMe Starter Kit properly!\n"); //Confirmation
while (1) { start of main loop
output_d(0x00); //Turn off LEDs
delay_ms(500); //for 0.5sec
output_d(a); //Turn on LEDs
delay_ms(500); //for 0.5s
if (!input(PIN_B0)) //if SW1 is pressed for a while
{
printf("\n value of a: %X\n",a); //display value of a in hex format
}
while(!input(PIN_B0)); //stop while SW1 is pressed
{a++; //Increment a}
if(a>=0xFF)
{a=0;}
}// end of main loop
} //End of program

_________________________________________________________

PICMe Testing

a)Test source code(test_877A.c)
_________________________________________________________
//this is a test program to check the PICMe board and the serial communication


#include <16f877a.h>
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6, rcv=PIN_C7) //serial communication

void main()
{
int i;
delay_ms(2000);
output_d(0);
i=128;

printf("\nPICMe Ready OK!\n");
printf("press any key and click send...\n\r");

output_high(PIN_D7);

getc();
printf("\nyou can now see the LEDs in motion!\n\r");
printf("\n...toggle DTR if you want to reset the program or press RESET button!\n");

while(1) //running light
{
output_d(i);
delay_ms(100);
if(shift_right(&i,1,0)==1) i=128;
}

}
____________________________________________________


b)Test Hex file(test_877A.hex)
____________________________________________________
:1000000000308A00CB2800000A108A100A118207EB
:100010000A345034493443344D3465342034523436
:10002000653461346434793420344F344B342134B2
:100030000A3400340A108A100A11820770347234AC
:10004000653473347334203461346E34793420343D
:100050006B3465347934203461346E346434203444
:1000600063346C34693463346B34203473346534F2
:100070006E3464342E342E342E340A340D3400346D
:100080000A108A100A1182070A3479346F347534E1
:100090002034633461346E3420346E346F347734FA
:1000A00020347334653465342034743468346534F2
:1000B00020344C34453444347334203469346E3441
:1000C00020346D346F34743469346F346E342134B9
:1000D0000A340D3400340A108A100A1182070A34D7
:1000E0002E342E342E3474346F34673467346C34C9
:1000F0006534203444345434523420346934663402
:10010000203479346F3475342034773461346E346C
:100110007434203474346F3420347234653473345E
:100120006534743420347434683465342034703465
:1001300072346F346734723461346D3420346F3408
:100140007234203470347234653473347334203430
:100150005234453453344534543420346234753485
:10016000743474346F346E3421340A3400342330E0
:100170008400831300080319CA280630F800F70129
:10018000F70BC028F80BBF287B30F700F70BC62809
:10019000800BBD280034840183131F308305813018
:1001A00083169900A6309800903083129800831629
:1001B0001F149F141F159F1107309C0008308312D5
:1001C000A200FA30A300B720A20BE1288316880111
:1001D000831288018030A100A20122080420A20A13
:1001E000F70077080C1EF228990011302202031D37
:1001F000ED28A20122081A20A20AF70077080C1E97
:10020000FF28990021302202031DFA288316881343
:10021000831288178C1E0A291A08A201220840207E
:10022000A20AF70077080C1E132999002630220233
:10023000031D0E29A20122086B20A20AF7007708ED
:100240000C1E2029990047302202031D1B2983160A
:1002500088018312210888006430A300B7200310AE
:0E026000A10C031C35298030A1002729630062
:02400E00323F3F
:00000001FF
;PIC16F877A
____________________________________________________

MPASM SAMPLE PROGRAM
____________________________________________________
LIST p=16F877A
#include p16f877a.inc ;include file with config bit definitions
__config 0x3F3A
;Set oscillator to HS,
;_XT_OSC & _WDT_OFF & _LVP_OFF
;watchdog time off,
;low-voltage prog. off

;---------General Purpos Register /Declarations of Variables--------------
;----------------------------------------------------------------------------------------
cblock 0x20 ; General Purpose Register
count ;used in looping routines
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
tmp1 ;temporary storage
endc
;-------------------------------------------------------------------------
STATUS equ 0x03 ; assign register addresses
PORTD equ 0x08
TRISD equ 0x88

org 0x03 ;load program starting at memory address 0x03
movlw 0x00 ;set-up program counter
movwf 0xA
goto INIT
nop
INIT clrf 0x04 ; clear indirect addressing register

;-----------------------------START of the Program--------------------------------
START bsf STATUS, 5 ; select Bank 1
clrf TRISD ;set Port D to output
bcf STATUS, 5 ;select Bank 0


Main ;Main Loop
movlw 0xff
movwf PORTD ;output 0xff to Port D
Call Delay1Sec ; wait for atleast 1 second.
movlw 0x00
movwf PORTD ;output 0xff to Port D
goto Main ;continuous loop
;----------------------------------------------------------------------------------

;------------------------------Delay for 1 second ---------------------------
Delay1Sec
call Delay250
call Delay250
call Delay250
call Delay250
Return

Delay255 movlw 0xff ;delay 255mS
goto d0
Delay250 movlw d'250' ;delay 250mS
goto d0
Delay100 movlw d'100' ;delay 100mS
goto d0
Delay50 movlw d'50' ;delay 50mS
goto d0
Delay20 movlw d'20' ;delay 20mS
goto d0
Delay10 movlw d'10' ;delay 10mS
goto d0
Delay1 movlw d'1' ;delay 1mS
goto d0
Delay5 movlw 0x05 ;delay 5ms
d0 movwf count1
d1 movlw 0xE7
movwf counta
movlw 0x04
movwf countb
Delay_0 decfsz counta, f
goto 2
decfsz countb, f
goto Delay_0
decfsz count1 ,f
goto d1
retlw 0x00
;------------------------- Delay for 1 second --------------------------
;------------------------------------------------------------------------------
sleep
END ;end of program
____________________________________________________

Acknowledgments:

ASTI-Embedded Groups
Art Becker-Technical expertise and assistance

Wednesday, January 20, 2010

SDCC & Embedded Linux

Tutorials for PIC in Linux C Compiler-SDCC

Tuesday, January 19, 2010