background image

 2001 Microchip Technology Inc.

DS39024B-page 15

Using the PICDEM 17 Monitor

Figure 2.7:  Writing Data Memory

To write to a Data memory location, the user must first select the Data 
Memory
 radio button in the Modify Memory window of the Monitor program. 
Then the Data memory address must be written into the Address edit box. 
The format of this value is bxx, where b is a valid bank number in HEX 
format, and xx is a value from 00h to FFh that indicates the desired address 
within the bank to write. The user must also enter the value to be written to the 
Data register in the Value edit box. Then click the Write button. The message 
window will reply with the following message: *WDbxxdd. bxx represents the 
bank and address and dd represents the data written to the address in HEX 
format. For this operation the first three digits in the Address edit box and first 
two digits in the Value edit box are used when the command is sent to the 
PICDEM 17 demonstration board. Any additional digits are ignored.

Summary of Contents for Picdem 17

Page 1: ...PICDEM 17 DEMONSTRATION BOARD USER S GUIDE 2001 Microchip Technology Inc DS39024B ...

Page 2: ...rwise under any intellectual prop erty rights Trademarks The Microchip name logo PIC PICmicro PICMASTER PIC START PRO MATE KEELOQ SEEVAL MPLAB and The Embedded Control Solutions Company are registered trade marks of Microchip Technology Incorporated in the U S A and other countries Total Endurance In Circuit Serial Programming ICSP Filter Lab FlexROM fuzzyLAB ICEPIC microID MPASM MPLIB MPLINK MXDE...

Page 3: ...ing Areas 4 1 8 Oscillator Options 5 1 9 RS 232 Serial Ports 5 1 10 Push button Switches 5 1 11 LEDs 5 1 12 Analog Circuitry 5 1 13 External LCD Interface 5 1 14 CAN Bus Interface 6 1 15 24LC01B Serial EEPROM 6 1 16 Modular Connectors 6 1 17 Pre programmed Sample 6 Chapter 2 Using the PICDEM 17 Monitor 2 1 Introduction 7 2 2 Highlights 7 2 3 Installing the PICDEM 17 Monitor Program 7 2 4 Using the...

Page 4: ...ections 19 3 4 Push button Switches 20 3 5 DIP Switches 20 3 6 RS 232 Interface 20 3 7 CAN Bus Interface 20 3 8 Modular Connectors 21 Chapter 4 Using the MPLAB C17 C Compiler 4 1 Introduction 23 4 2 Highlights 23 4 3 Linker Script File 24 4 4 Startup Code File 26 4 5 Interrupt Code File 28 4 6 Other Files 33 Chapter 5 LCD C Description 5 1 Introduction 35 5 2 MPLAB IDE Project Files 35 5 3 PICmicr...

Page 5: ...ource Code Listing 63 Chapter 8 SWITCH C Description 8 1 Introduction 65 8 2 Highlights 65 8 3 MPLAB IDE Project Files 65 8 4 PICmicro C Libraries 66 8 5 Source Code Descriptions 66 8 6 SWITCH C Source Code Listing 67 Chapter 9 I2C C Description 9 1 Introduction 69 9 2 Highlights 69 9 3 MPLAB IDE Project Files 69 9 4 PICmicro C Libraries 70 9 5 Source Code Descriptions 70 9 6 I2C C Source Code Lis...

Page 6: ...39024B page 6 2001 Microchip Technology Inc Appendix B RS 232 Communication Protocol B 1 Introduction 81 B 2 Overview 81 B 3 Detailed Description 81 Appendix C Floppy Disk Contents C 1 Introduction 83 C 2 Contents 83 Worldwide Sales and Service 86 ...

Page 7: ... the PICDEM 17 demonstration board and provides a brief description of the hardware Chapter 2 Using the PICDEM 17 Monitor This chapter discusses how to use the PICDEM 17 Monitor PC program and the pre programmed PIC17C756A device Chapter 3 Hardware Description This chapter describes in detail the hardware of the PICDEM 17 demonstration board Chapter 4 Using MPLAB C17 C compiler with PICDEM 17 demo...

Page 8: ...stration board parts layout diagram and the board schematics Appendix B RS 232 Communication Protocol This appendix provides the protocol for the PIC17C756A Monitor firmware to communicate to the PC based software Appendix C Floppy Disk Contents This appendix contains a listing of all files on the included 3 5 inch floppy disk There is also a description as to the use of each file when compiling p...

Page 9: ...S 232 Serial Ports Push button Switches LEDs Analog Circuitry External LCD Interface CAN Bus Interface 24LC01B Serial EEPROM Modular Connectors Pre programmed Sample 1 3 Processor Sockets The PICDEM 17 demonstration board supports the following devices 68 pin PLCC socket for the PIC17C75X microcontrollers U1 84 pin PLCC socket for the PIC17C76X microcontrollers U7 Note All following part reference...

Page 10: ...V up to 1A unregulated Alternating Current AC or Direct Current DC can be used The digital components on the board are powered from a LM2940T 5 0 that is capable of supplying 1A of current This digital 5V is available in the digital prototyping area in the upper right hand corner of the board The analog section of the PICDEM 17 demonstration board has a separate power source and voltage reference ...

Page 11: ...memory mapped These LEDs may be accessed at address FFFDh There is no read capability for the LEDs so the user must have a shadow register in the PIC17C7XX device to keep track of the value on the latch 1 12 Analog Circuitry In addition to the power and ground planes on the PICDEM 17 demonstration board it also has separate analog and digital power supplies Both of these voltage regulators use con...

Page 12: ...The modular connectors J4 and J5 can also be used to create an I2 C interface to a peripheral not located on the board 1 16 Modular Connectors The modular connectors J4 and J5 are used to connect to external busses The DIP switch S14 is used to determine if the CAN Bus interface is used or the I2 C interface If the CAN Bus is the desired interface the user will have to populate the board with the ...

Page 13: ...r Program The PICDEM 17 Monitor program setup routine installs the monitor program PC monitor source code and the PIC17C756A monitor source code into the MPLAB IDE directory Microsoft Windows 95 must be running to execute the Monitor Setup program The files can be installed under the default MPLAB IDE directory C Program Files MPLAB 756MON or in another directory 1 Insert the PICDEM 17 Monitor ins...

Page 14: ...ICDEM 17 demonstration board Then apply power to the PICDEM 17 demonstration board The PICDEM 17 demonstration board should display the following message in the message window on the Monitor Program Boot Mon V where is the version of the Monitor firmware in the PIC17C756A The Monitor program has many features including Resetting the PIC17C756A on the PICDEM 17 demonstration board Erasing the FLASH...

Page 15: ...Erase button This simply erases the FLASH memory When a download is requested the PIC17C756A automatically erases the FLASH Therefore it is not required that the FLASH be erased using the Erase button before a download is initiated 2 7 Downloading HEX Files to the PICDEM 17 Demonstration Board To download a HEX file to the PICDEM 17 demonstration board first click on Download This will open a Sele...

Page 16: ...l FLASH program memory Once a program has been downloaded into the FLASH memory click the Run button to start execution Control of the PIC17C756A is released by the Monitor firmware by simply writing 4000h to the PCLATH PCL registers Refer to Chapter 4 Using the MPLAB C17 C Compiler for more information Figure 2 4 Program Running on PICDEM 17 Demonstration Board The only way to stop the program fr...

Page 17: ... FLASH memory diagnostic simply writes all zero s all one s checkerboard and inverse checkerboard to a portion of memory and checks to make sure that the values were properly written This diagnostic does not require any user interaction I2 C This diagnostic writes an incrementing count to the 24LC01B Serial EEPROM on the PICDEM 17 demonstration board and verifies that each location has been proper...

Page 18: ...switches and LEDs Each time a switch is pressed the corre sponding LED is turned OFF This diagnostic ends when all LEDs have been turned OFF USART2 This diagnostic writes a message to the Monitor program running on the PC Host This diagnostic does not require any interac tion from the user To run a diagnostic highlight the desired test in the Diagnostics window of the Monitor program Then click th...

Page 19: ... 2001 Microchip Technology Inc DS39024B page 13 Using the PICDEM 17 Monitor Figure 2 5 Running Diagnostics ...

Page 20: ...ser must first select the Data Memory radio button in the Modify Memory window of the Monitor program Then the Data memory address must be written into the Address edit box The format of this value is bxx where b is a valid bank number in HEX format and xx is a value from 00h to FFh that indicates the desired address within the bank to read Then click the Read button The message window will reply ...

Page 21: ...at and xx is a value from 00h to FFh that indicates the desired address within the bank to write The user must also enter the value to be written to the Data register in the Value edit box Then click the Write button The message window will reply with the following message WDbxxdd bxx represents the bank and address and dd represents the data written to the address in HEX format For this operation...

Page 22: ...Address edit box The format of this value is xxxx where xxxx is a value from 0000h to FFFFh that indicates the desired address within the 64K address space to read Then click the Read button The message window will reply with the following message RPxxxx dddd xxxx represents the program memory address and dddd represents the data at that address in HEX format For this operation the first four digi...

Page 23: ...hin the bank to write The user must also enter the value to be written to the program memory location in the Value edit box Then click the Write button The message window will reply with the following message WPxxxxdddd xxxx represents the program memory address and dddd represents the data written to the address in HEX format For this operation the first four digits of both the Address edit box a...

Page 24: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 18 2001 Microchip Technology Inc NOTES ...

Page 25: ...ot used PORTA 2 3 used for SPI I2 C interface PORTA 4 5 used for USART1 interface PORTB 0 3 not used PORTB 4 5 used for USART2 handshaking interface CTS RTS PORTB 6 7 used for SPI I2 C interface All of PORTC and PORTD are dedicated to the external memory inter face PORTE 0 2 are used in the external memory interface as ALE OE and WR respectively PORTF 0 3 are used as the data lines for the externa...

Page 26: ...witch is also labeled to SDA SCL for I2 C or CANH CANL for CAN Bus 3 6 RS 232 Interface The PICDEM 17 demonstration board provides a RS 232 interface device U3 to convert between RS 232 voltage levels and CMOS TTL voltage levels Both USART1 and USART2 I O pins are routed to this device as well as the I O pins used for hardware handshaking The DB9 connector P1 is used for USART1 and P2 is used for ...

Page 27: ...re Description 3 8 Modular Connectors As described previously the modular connectors can be used to set up a CAN Bus or a I2C Bus by simply connecting standard 4 or 6 conductor phone cable Refer to Figure A 1 in Appendix A for the pinout of the connectors ...

Page 28: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 22 2001 Microchip Technology Inc NOTES ...

Page 29: ...inker script file DEMO756 LKR is described as well as other support files 4 2 Highlights This chapter covers the following topics Linker Script File DEMO756 LKR Startup Code File C0L17DEM ASM Interrupt Code File INT756LD ASM Other Files Note 1 User should refer to MPLAB IDE document that shows project setup but special version of linker scripts etc are used here because of the demonstration board ...

Page 30: ...rst two pages are used by on chip monitor program CODEPAGE NAME PAGE0 START 0x0028 END 0x1FFF CODEPAGE NAME PAGE1 START 0x2000 END 0x3FFF Your program starts in page 2 First 28h locations of page 2 are vectors CODEPAGE NAME PAGE2 START 0x4028 END 0x5FFF CODEPAGE NAME PAGE3 START 0x6000 END 0x7FFF CODEPAGE NAME PAGE4 START 0x8000 END 0x9FFF CODEPAGE NAME PAGE5 START 0xA000 END 0xBFFF CODEPAGE NAME ...

Page 31: ...ECTED NAME SSR7 START 0x710 END 0x717 3 SFRs shared 0x18 to 0x19 SHAREBANK PROTECTED NAME SFRShareB START 0x018 END 0x019 General Purpose Data Memory 1 GPRs that are shared 0x1A to 0x1F SHAREBANK NAME GPRShare START 0x01A END 0x01F 2 GPRs in banks 0 1 DATABANK NAME GPR0 START 0x020 END 0x0FF DATABANK NAME GPR1 START 0x120 END 0x1FF DATABANK NAME GPR2 START 0x220 END 0x2FF DATABANK NAME GPR3 START ...

Page 32: ...r 3 in the user s guide for more information The following two statements determine whether you wish to use initialized data in your C programs and whether you wish to have a __STARTUP function called upon reset Please note that if you turn USE_STARTUP on then you must defined a __STARTUP in your code or you will get a linker error DEFINE USE_INITDATA Uncomment if you use initialized data DEFINE U...

Page 33: ...a from program memory to data memory IFDEF USE_INITDATA movlw HIGH copy_init_data movwf PCLATH lcall copy_init_data ENDIF Set up the stack for use with function arguments and local auto variables _setup_stack BANKSEL _stack Switch to bank where the stack pointer is movlw _stack 2 Store the address of the stack pointer 2 movwf _stack Into the stack pointer Branch to main in the C program movlw HIGH...

Page 34: ...A Interrupt Support File Version 1 10 L a r g e M o d e l PIC1DEM 17 Workshop Demo Board Version c Copyright 1997 Microchip Technology list p 17c756 Equates PCL equ 0x02 PCLATH equ 0x03 ALUSTA equ 0x04 BSR equ 0x0F WREG equ 0x0A SAVEINT_START equ 0x00FC Start of shared region for int saving INTSAVE_SEC UDATA SAVEINT_START Save registers that absolutely need to be saved save_BSR RES 1 Used for savi...

Page 35: ... H 4008 Save ALUSTA movpf ALUSTA save_ALUSTA must save ALUSTA before others movpf WREG save_WREG temporarily save off WREG Branch to prolog movlw HIGH _INT_prolog movwf PCLATH movlw LOW _INT_prolog movwf PCL _TMR0_sec CODE H 4010 Save ALUSTA movpf ALUSTA save_ALUSTA must save ALUSTA before others movpf WREG save_WREG temporarily save off WREG Branch to prolog movlw HIGH _TMR0_prolog movwf PCLATH m...

Page 36: ...ovlw LOW _PIV_prolog movwf PCL InterruptCode CODE _INT_prolog Save BSR and WREG movfp BSR PCLATH clrf BSR 1 movpf PCLATH save_BSR Service the interrupt by calling the interrupt handling function goto _INT_2 _INT_1 BANKSEL fpINT movfp fpINT 1 PCLATH movfp fpINT PCL _INT_2 call _INT_1 push address of next instruction on stack Restore WREG and BSR clrf BSR 1 BSR was saved in bank 0 movfp save_BSR BSR...

Page 37: ...EG WREG and WREG as well Restore PCLATH and ALUSTA movfp save_PCLATH PCLATH movfp save_ALUSTA ALUSTA Return from interrupt RETFIE _T0CKI_prolog Save BSR and WREG movfp BSR PCLATH clrf BSR 1 movpf PCLATH save_BSR Service the interrupt by calling the interrupt handling function goto _T0CKI_2 _T0CKI_1 BANKSEL fpT0CKI movfp fpT0CKI 1 PCLATH movfp fpT0CKI PCL _T0CKI_2 call _T0CKI_1 push address of next...

Page 38: ...ng the interrupt handling function goto _PIV_2 _PIV_1 BANKSEL fpPIV movfp fpPIV 1 PCLATH movfp fpPIV PCL _PIV_2 call _PIV_1 push address of next instruction on stack Restore WREG and BSR clrf BSR 1 BSR was saved in bank 0 movfp save_BSR BSR Now restore it movfp save_WREG WREG and WREG as well Restore PCLATH and ALUSTA movfp save_PCLATH PCLATH movfp save_ALUSTA ALUSTA Return from interrupt RETFIE E...

Page 39: ...SM assembler and linked in with the rest of the files The only other file that might be used to compile programs for the PICDEM 17 demonstration board may be the library object module For the PIC17C756A microcontroller the library file PMC756L LIB would be linked with the rest of the files Note 1 User should refer to MPLAB IDE document that shows project setup but special version of linker scripts...

Page 40: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 34 2001 Microchip Technology Inc NOTES ...

Page 41: ...el using the interface provided on PICDEM 17 demonstration board Highlights This chapter covers the following topics MPLAB IDE Project Files PICmicro C Libraries Source Code Descriptions LCD C Source Code Listing XLCD H Source Code Listing XLCD C Source Code Listing 5 2 MPLAB IDE Project Files The project LCD PJT contains the following files The files in this project use the following header files...

Page 42: ...pt file PMC756L LIB This file contains the library functions compiled for large memory model it is included by the linker script file C0L17DEM O This file contains the startup code to initialize the stack initialize data call the startup function and jump to main LCD C This file is the main source code file for the project XLCD C This file contains the source code to interface to the external LCD ...

Page 43: ... or equivalent The first line shows Hello and the second line shows World Uses an oscillator of 16MHz include p17c756 h include delays h include xlcd h Constant string arrays in program memory const rom char Hello Hello const rom char World World Delays for 18 Tcy void DelayFor18TCY void Delay10TCY Delay10TCY return Delays for 15ms void DelayPORXLCD void Delay1KTCYx 70 return Delays for 5ms void D...

Page 44: ...logy Inc Print the Hello message to the first line putrsXLCD Hello Wait for the LCD to finish last command while BusyXLCD Set the cursor to the start of the 2nd line SetDDRamAddr 0x28 Print the World message to the 2nd line putrsXLCD World Endless loop to end program while 1 Nop Nop ...

Page 45: ...ether using the upper or lower nibble The data port The tris register for data port The control signal ports and pins The control signal port tris and pins The user must provide three delay routines DelayFor18TCY provides a 18 Tcy delay DelayPORXLCD provides at least 15ms delay DelayXLCD provides at least 5ms delay ifndef __XLCD_H define __XLCD_H Interface type 8 bit or 4 bit For 4 bit operation c...

Page 46: ... Function Set defines define FOUR_BIT 0b00101111 4 bit Interface define EIGHT_BIT 0b00111111 8 bit Interface define LINE_5X7 0b00110011 5x7 characters single line define LINE_5X10 0b00110111 5x10 characters define LINES_5X7 0b00111111 5x7 characters multiple line Other Functions define CLS 0b00000001 Clear display Set DDRAM to 0 define HOME 0b00000010 Set DDRAM to 0 void OpenXLCD static unsigned c...

Page 47: ... LCD void putrsXLCD static const rom char Writes a string of characters in ROM to the LCD User defines these routines according to the oscillator frequency extern far void DelayFor18TCY void extern far void DelayPORXLCD void extern far void DelayXLCD void endif pragma list ...

Page 48: ...teDataXLCD char data void putsXLCD char buffer void putrsXLCD const rom char buffer Revision History V1 00 Beta release of Peripheral Libraries for V1 21 V2 00 Release of Peripheral Libraries for V2 00 V2 10 Release of Peripheral Libraries for V2 10 Notes ROM usage varies depending on specified device Function Name putsXLCD Return Value void Parameters buffer pointer to string Description This rou...

Page 49: ...ding on what the previous SetxxRamAddr routine was called void putrsXLCD static const rom char buffer while buffer Write data to LCD up to null while BusyXLCD Wait while LCD is busy WriteDataXLCD buffer Write character to LCD buffer Increment buffer return Function Name OpenXLCD Return Value void Parameters lcdtype sets the type of LCD lines Description his routine configures the LCD Based on the ...

Page 50: ...uts TRIS_RS 0 TRIS_E 0 RW_PIN 0 R W pin made low RS_PIN 0 Register select pin made low E_PIN 0 Clock pin made low Delay for 15ms to allow for LCD Power on reset DelayPORXLCD Setup interface to LCD ifdef BIT8 8 bit mode inter face TRIS_DATA_PORT 0 Data port output DATA_PORT 0b00110000 Function set cmd 8 bit interface else 4 bit mode inter face ifdef UPPER Upper nibble interface TRIS_DATA_PORT 0x0f ...

Page 51: ...N 0 Delay for at least 100us DelayXLCD Setup interface to LCD ifdef BIT8 8 bit interface DATA_PORT 0b00110000 Function set cmd 8 bit interface else 4 bit interface ifdef UPPER Upper nibble interface DATA_PORT 0x0f Function set cmd 4 bit interface DATA_PORT 0b00110000 else Lower nibble interface DATA_PORT 0xf0 Function set cmd 4 bit interface DATA_PORT 0b00000011 endif endif E_PIN 1 Clock cmd in De...

Page 52: ...it if LCD busy WriteCmdXLCD DOFF CURSOR_OFF BLINK_OFF Display OFF Blink OFF while BusyXLCD Wait if LCD busy WriteCmdXLCD DON CURSOR_ON BLINK_ON Display ON Blink ON Clear display while BusyXLCD Wait if LCD busy WriteCmdXLCD 0x01 Clear display Set entry mode inc no shift while BusyXLCD Wait if LCD busy WriteCmdXLCD SHIFT_CUR_LEFT Entry Mode Set DD Ram address to 0 while BusyXLCD Wait if LCD busy Set...

Page 53: ...def UPPER Upper nibble interface TRIS_DATA_PORT 0x0f DATA_PORT 0x0f DATA_PORT cmd 0xf0 else Lower nibble interface TRIS_DATA_PORT 0xf0 DATA_PORT 0xf0 DATA_PORT cmd 4 0x0f endif RW_PIN 0 Set control sig nals for command RS_PIN 0 DelayFor18TCY E_PIN 1 Clock command in DelayFor18TCY E_PIN 0 ifdef UPPER Upper nibble interface DATA_PORT 0x0f DATA_PORT cmd 4 0xf0 else Lower nibble interface DATA_PORT 0x...

Page 54: ...b01000000 Write cmd and address to port RW_PIN 0 Set control sig nals RS_PIN 0 DelayFor18TCY E_PIN 1 Clock cmd and address in DelayFor18TCY E_PIN 0 DelayFor18TCY TRIS_DATA_PORT 0xff Make data port inputs else 4 bit interface ifdef UPPER Upper nibble interface TRIS_DATA_PORT 0x0f Make nibble input DATA_PORT 0x0f and write upper nibble DATA_PORT CGaddr 0b01000000 0xf0 else Lower nibble interface TRI...

Page 55: ...his routine sets the display data address of the Hitachi HD44780 LCD controller The user must check to see if the LCD controller is busy before calling this routine void SetDDRamAddr static unsigned char DDaddr while BusyXLCD ifdef BIT8 8 bit interface TRIS_DATA_PORT 0 Make port output DATA_PORT DDaddr 0b10000000 Write cmd and address to port RW_PIN 0 Set the control bits RS_PIN 0 DelayFor18TCY E_...

Page 56: ...DDaddr 4 0xf0 else Lower nibble interface DATA_PORT 0xf0 Write lower nib ble DATA_PORT DDaddr 0x0f endif DelayFor18TCY E_PIN 1 Clock the cmd and address in DelayFor18TCY E_PIN 0 ifdef UPPER Upper nibble interface TRIS_DATA_PORT 0xf0 Make port input else Lower nibble interface TRIS_DATA_PORT 0x0f Make port input endif endif return Function Name BusyXLCD Return Value char busy status of LCD controll...

Page 57: ...ace if DATA_PORT 0x80 else Lower nibble interface if DATA_PORT 0x08 endif E_PIN 0 Reset clock line DelayFor18TCY E_PIN 1 Clock out other nibble DelayFor18TCY E_PIN 0 RW_PIN 0 Reset control line return 1 Return TRUE else Busy bit is low E_PIN 0 Reset clock line DelayFor18TCY E_PIN 1 Clock out other nibble DelayFor18TCY E_PIN 0 RW_PIN 0 Reset control line return 0 Return FALSE endif Function Name Re...

Page 58: ... the reg ister E_PIN 0 RW_PIN 0 Reset the control bits else 4 bit interface RW_PIN 1 Set control bits for the read RS_PIN 0 DelayFor18TCY E_PIN 1 Clock data out of the LCD controller DelayFor18TCY ifdef UPPER Upper nibble interface data DATA_PORT 0xf0 Read the nibble into the upper nibble of data else Lower nibble interface data DATA_PORT 4 0xf0 Read nibble to upper nibble of data endif E_PIN 0 Re...

Page 59: ... char data ifdef BIT8 8 bit interface RS_PIN 1 Set the control bits RW_PIN 1 DelayFor18TCY E_PIN 1 Clock the data out of the LCD DelayFor18TCY data DATA_PORT Read the data E_PIN 0 RS_PIN 0 Reset the control bits RW_PIN 0 else 4 bit interface RW_PIN 1 RS_PIN 1 DelayFor18TCY E_PIN 1 Clock the data out of the LCD DelayFor18TCY ifdef UPPER Upper nibble interface data DATA_PORT 0xf0 Read the upper nibb...

Page 60: ...alling this routine The data is written to the character generator RAM or the display data RAM depending on what the previous SetxxRamAddr routine was called void WriteDataXLCD static char data while BusyXLCD ifdef BIT8 8 bit interface TRIS_DATA_PORT 0 Make port output DATA_PORT data Write data to port RS_PIN 1 Set control bits RW_PIN 0 DelayFor18TCY E_PIN 1 Clock data into LCD DelayFor18TCY E_PIN...

Page 61: ... 0 ifdef UPPER Upper nibble interface DATA_PORT 0x0f DATA_PORT data 4 0xf0 else Lower nibble interface DATA_PORT 0xf0 DATA_PORT data 0x0f endif DelayFor18TCY E_PIN 1 Clock nibble into LCD DelayFor18TCY E_PIN 0 ifdef UPPER Upper nibble interface TRIS_DATA_PORT 0xf0 else Lower nibble interface TRIS_DATA_PORT 0x0f endif endif return ...

Page 62: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 56 2001 Microchip Technology Inc NOTES ...

Page 63: ...displays it on the Monitor program using USART2 and hardware handshaking 6 2 Highlights This chapter covers the following topics MPLAB IDE Project Files PICmicro C Libraries Source Code Descriptions USART C Source Code Listing 6 3 MPLAB IDE Project Files The project USART PJT contains the following files The files in this project use the following header files P17C756 H DELAYS H USART16 H STDLIB H...

Page 64: ...cluded by the linker script file PMC756L LIB This file contains the library functions compiled for large memory model it is included by the linker script file C0L17DEM O This file contains the startup code to initialize the stack initialize data call the startup function and jump to main USART C This file is the main source code file for the project P17C756 H This header file contains processor sp...

Page 65: ...de p17c756 h include delays h include usart16 h include stdlib h void PutsUSART2 char data Function to print a string to USART2 using handshaking void PutsUSART2 char data do Wait for USART to complete prev operation while BusyUSART2 Hardware handshaking for CTS while PORTBbits RB4 Print a character to USART2 putcUSART2 data while data Increment pointer and check for NULL return void main void uns...

Page 66: ...H_MODE USART_EIGHT_BIT USART_CONT_RX 25 Send a carriage return and linefeed PutsUSART2 crlf Initialize the count variable i 0 while 1 Convert the count variable to ASCII ubtoa i str Print the string PutsUSART2 str Print a carriage return and linefeed PutsUSART2 crlf Wait for a while Delay10KTCYx 250 Delay10KTCYx 250 Increment the count variable i ...

Page 67: ...displays the result in ASCII on the Monitor program The A D module is configured to use the AVDD and AVSS pins as the voltage reference Highlights This chapter covers the following topics MPLAB IDE Project Files PICmicro C Libraries Source Code Descriptions ANALOG C Source Code Listing MPLAB IDE Project Files The project ANALOG PJT contains the following files The files in this project use the fol...

Page 68: ...linker script file PMC756L LIB This file contains the library functions compiled for large memory model it is included by the linker script file C0L17DEM O This fwwile contains the startup code to initialize the stack initialize data call the startup function and jump to main ANALOG C This file is the main source code file for the project P17C756 H This header file contains processor specific item...

Page 69: ...6MHz include p17c756 h include delays h include usart16 h include stdlib h include adc16 h void PutsUSART2 char data Prints a string to USART2 using hardware handshaking void PutsUSART2 char data do Wait for the USART to finish prev operation while BusyUSART2 Wait for CTS while PORTBbits RB4 Print character to USART2 putcUSART2 data while data Increment pointer and check for NULL return void main ...

Page 70: ...ze the A D OpenADC ADC_INT_OFF ADC_FOSC_32 ADC_RIGHT_JUST ADC_VREF_INT ADC_4ANA_8DIG ADC_CH0 Print a carriage return and linefeed PutsUSART2 crlf while 1 ConvertADC Start a conversion while BusyADC Wait to complete result ReadADC Read result uitoa result str Convert to ASCII PutsUSART2 str Print string to USART PutsUSART2 crlf Print crlf to USART Delay10KTCYx 250 Wait a while Delay10KTCYx 250 ...

Page 71: ...n the corresponding pushbutton switch is pressed the microcontroller will toggle the state of the LED 8 2 Highlights This chapter covers the following topics MPLAB IDE Project Files PICmicro C Libraries Source Code Descriptions SWITCH C Source Code Listing 8 3 MPLAB IDE Project Files The project SWITCH PJT contains the following files The files in this project use the following header files P17C75...

Page 72: ...for the project P17C756 O linker script file PMC756L LIB This file contains the library functions compiled for large memory model it is included by the linker script file C0L17DEM O This file contains the startup code to initialize the stack initialize data call the startup function and jump to main SWITCH C This file is the main source code file for the project P17C756 H This header file contains...

Page 73: ...elays h void main void unsigned int LEDbuf unsigned int SWTbuf unsigned int TEMPbuf unsigned int Temp rom int LEDptr rom int SWTptr Initialize pointers to the memory mapped device LEDptr rom int 0xfffd SWTptr rom int 0xfffc Initialize the LEDs and other variables LEDptr 0x00ff LEDbuf 0x00ff SWTbuf 0x00ff while 1 Read the state of the switches TEMPbuf SWTptr 0x00ff Determine what switch states have...

Page 74: ...tration Board User s Guide DS39024B page 68 2001 Microchip Technology Inc else OR in desired LED LEDbuf Temp Write new value to LEDs LEDptr LEDbuf Update switch state buffer SWTbuf TEMPbuf Wait for 16ms Delay1KTCYx 64 ...

Page 75: ...LEDs This program also displays the desired value and the actual value for each location Before running this program make sure that S3 positions 1 and 2 are ON and the rest are OFF 9 2 Highlights This chapter covers the following topics MPLAB IDE Project Files PICmicro C Libraries Source Code Descriptions I2C C Source Code Listing 9 3 MPLAB IDE Project Files The project I2C PJT contains the follow...

Page 76: ...contains the processor dependent objects it is included by the linker script file PMC756L LIB This file contains the library functions compiled for large memory model it is included by the linker script file C0L17DEM O This file contains the startup code to initialize the stack initialize data call the startup function and jump to main I2C C This file is the main source code file for the project P...

Page 77: ...e to the USART2 for display on the Monitor program The address is also displayed on the memory mapped LEDs Uses an oscillator of 16MHz include p17c756 h include delays h include i2c16 h include usart16 h include stdlib h void PutsUSART2 char data void PutcUSART2 char data Prints a string to USART2 using hardware handshaking void PutsUSART2 char data do Wait for USART2 to finish prev operation whil...

Page 78: ... USART2 and hardware handshaking PORTBbits RB5 1 DDRBbits RB5 0 OpenUSART2 USART_TX_INT_OFF USART_RX_INT_OFF USART_ASYNCH_MODE USART_EIGHT_BIT USART_CONT_RX 25 Print a carriage return and linefeed PutsUSART2 crlf Initialize address to 0 addr 0 while 1 LEDptr addr Write address to LEDs Write a byte to the EEPROM EEByteWrite 0xa0 addr addr Wait for the EEPROM EEAckPolling 0xa0 Read a byte from the E...

Page 79: ... 2001 Microchip Technology Inc DS39024B page 73 I2 C C Description PutsUSART2 crlf Print a CRLF to USART2 addr Increment the address if addr 127 If 127 addr 0 reset to 0 Delay10KTCYx 250 Wait a while ...

Page 80: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 74 2001 Microchip Technology Inc NOTES ...

Page 81: ... 2001 Microchip Technology Inc DS39024B page 75 PICDEM 17 DEMONSTRATION BOARD USER S GUIDE 12 Appendix A PICDEM 17 Demonstration Board Schematics Figure A 1 PICDEM 17 Demonstration Board Parts Layout ...

Page 82: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 76 2001 Microchip Technology Inc A 1 SCHEMATIC 1 ...

Page 83: ... 2001 Microchip Technology Inc DS39024B page 77 PICDEM 17 Demonstration Board Schematics A 2 SCHEMATIC 2 ...

Page 84: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 78 2001 Microchip Technology Inc A 3 SCHEMATIC 3 ...

Page 85: ... 2001 Microchip Technology Inc DS39024B page 79 PICDEM 17 Demonstration Board Schematics A 4 SCHEMATIC 4 ...

Page 86: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 80 2001 Microchip Technology Inc NOTES ...

Page 87: ...I text which means that any terminal program can be used to communicate with the firmware The Monitor program was developed as a convenience to the user When using a terminal program the H command will display all the available commands to the user Descriptions of the operation of the diagnostics are given in Chapter 2 B 3 DETAILED DESCRIPTION The following are all the commands and associated desc...

Page 88: ...Guide DS39024B page 82 2001 Microchip Technology Inc For Data Memory operations b is the bank number xx is the data memory address dd is the 8 bit data value For Program Memory operations yyyy is the 16 bit address dddd is the 16 bit data ...

Page 89: ... Service Routine 17C756L LKR Linker Script File TESTLCD C Main Source Code File UTIL C Utility Routines XLCD C External LCD Routines XLCD H External LCD Header File C0L17 ASM Startup File PMC756L LIB Library Routines P17C756 ASM Processor Definition File PICDEM 17 PC Monitor Software 756MON C Source Code 756MON H Header File 756MON RC Resource File 756MON EXE Executable PICDEM 17 Files C0L17DEM AS...

Page 90: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 84 2001 Microchip Technology Inc NOTES ...

Page 91: ... 2001 Microchip Technology Inc DS39024B page 85 Floppy Disk Contents NOTES ...

Page 92: ...0 New York 150 Motor Parkway Suite 202 Hauppauge NY 11788 Tel 631 273 5305 Fax 631 273 5335 San Jose Microchip Technology Inc 2107 North First Street Suite 590 San Jose CA 95131 Tel 408 436 7950 Fax 408 436 7955 Toronto 6285 Northam Drive Suite 108 Mississauga Ontario L4V 1X5 Canada Tel 905 673 0699 Fax 905 673 6509 ASIA PACIFIC China Beijing Microchip Technology Beijing Office Unit 915 New China ...

Reviews: