Hi, This a program that i did for PIC17C756, and must be run in 2 external EEPROM TO O! If you see, the machine code are correct, start at 0000 address, goto _Setup_Sta ck (00c7 address), and goto main (00c2 address), but doesn't works! Today is not my day! :( Miguel. -------------------------------------------------------------------------------- --------- MP2COD v1.01, COFF to COD File Converter Copyright (c) 1997, Microchip Technology Inc. Listing File Generated: Wed Jul 1 13:16:08 1998 Address Value Disassembly Source File ------- ------- --------------------- ------------------------------------------------------------------------------- ----- // This is a template to start a new ma in C file // // Include processor header file and th e assignment for the Configuration Bits #include // Change to your required processors header file. #pragma list C:\MCC\H\p17c756.h // or the command line will specify the device! // Do Confi guration Bit assignments here #include "AD.H" // This inc lude file contains the // //***************************************************************************** // // The Include File: Prototypes the Functions used // // // File Name: AD.H // // Revision history Date Nam e Reason // ------- -------- --- --- ------------------------------- // 1.00 12/08/97 M. Palmer Initial Release // // // //***************************************************************************** #ifndef AD_H #define AD_H // // Global definitions // Put whatever other defininitions tha t are required here. // Example Preprocessor macro defini tions: // #define TRUE 1 #define FALSE 0 //***************************************************************************** // // Place function prototypes here (void = no value) // prototypes include: // void delay(void); // DELAY function (user function) // void __STARTUP(void); // Only R equired if using the // startu p function void _INT(void); // Only R equired if using (installing) // the IN T interrupt vector address void _TMR0(void); // Only R equired if using (installing) // the TM R0 interrupt vector address void _T0CKI(void); // Only R equired if using (installing) // the T0 CKI interrupt vector address void _PIV(void); // Only R equired if using (installing) // the Pe ripheral interrupt vector address void main(void); // Requir ed for the main function #endif // function prototypes // " "s for ces the compiler to look in current // director y for the file. // //***************************************************************************** // // The Program displays the 8 MSbs of t he A/D result on PORTD. After each // conversion, a delay is done so that LEDs are visable. // // File Name: AD.C // // Revision history Date Nam e Reason // ------- -------- --- --- ------------------------------- // 1.00 12/08/97 M. Palmer Initial Release // // // //***************************************************************************** // // Other include files // Example include file: // #include // Optional, Required if using bit definitions or #pragma list C:\MCC\H\stddef.h // other vari able types (such as variable type BYTE). void Sub(void); //***************************************************************************** // // Preprocessor macro definitions // Put whatever other defininitions tha t are required here. // Example Preprocessor macro defini tions: // //***************************************************************************** // // Optional __STARTUP() function. // This function executes before the ma in() function. This is where Device // initialization can be done. // //** To be able to use the __STARTUP fu nction, the Microchip supplied //** C0L17.ASM or C0S17.ASM file may ne ed to be modified. The USE_STARTUP must //** be defined (not commented out), an d the file will need to be re-assembled //** for the required device. The IDATA 17.O file must also be linked, since the //** startup calls a function that is l ocated in the IDATA17 object file. // // void __STARTUP(void) { 00bb b800 MOVLB 0x0 DDRB = 0; // PortB i s all Output 00bc 2911 CLRF 0x11,0x1 00bd 0002 RETURN } void Sub(void) { 00be b800 MOVLB 0x0 PORTB=0xFF; 00bf 2b12 SETF 0x12,0x1 00c0 2912 CLRF 0x12,0x1 PORTB=0x00; 00c1 0002 RETURN } //***************************************************************************** // // Required main() function. // This is the main routine of your pro gram. If interrupts are to be used, the // interrupts must be "installed". The definition of these "installs" is // found in all the P17Cxxx.H header fi les (ex: PIC17C756.H). // void main(void) { 00c2 b800 MOVLB 0x0 DDRB = 0; // PortB is all Output 00c3 2911 CLRF 0x11,0x1 while(1) // Add code here { 00c4 e0be CALL 0xbe Sub(); 00c5 c0c4 GOTO 0xc4 } 00c6 0002 RETURN } ;********************************************************************* ;** PIC17Cxx MPLAB-C v2.0 Assembly S tartup File, Version 1.00 ** ;** S m a l l M o d e l ** ;** (c) Copyright 1997 Microchip Tec hnology ** ;********************************************************************* ; ; This is the C startup assembly file f or the small model. Please ; refer to chapter 3 in the user's guid e for more information. ; The following two statements determin e whether you wish to use ; initialized data in your C programs a nd whether you wish to ; have a __STARTUP() function called up on reset. Please note that ; if you turn USE_STARTUP on, then you must define a __STARTUP() ; in your code or you will get a linker error. ;#DEFINE USE_INITDATA ;Uncomme nt if you use initialized data ; #DEFINE USE_STARTUP ;Uncom ment if you use __STARTUP() ;--------------------- E Q U A T E S -----------------------; PCL equ 0x02 PCLATH equ 0x03 ;----------------External variables and labels--------------; EXTERN _stack EXTERN main #IFDEF USE_STARTUP EXTERN __STARTUP #ENDIF #IFDEF USE_INITDATA EXTERN copy_init_data #ENDIF ;***********************************************************; RESET CODE H'0000' ;Location of re set vector ;-----------------------------------------------------------; ; ;-----------------------------------------------------------; ; Optionally call __STARTUP() ; ;-----------------------------------------------------------; #IFDEF USE_STARTUP call __STARTUP #ENDIF ;-----------------------------------------------------------; ; Branch to startup code ; ;-----------------------------------------------------------; 0000 c0c7 GOTO 0xc7 goto _start ;***********************************************************; _start_section CODE ;-----------------------------------------------------------; ; ;Beginning of startup code ; _start ;------------------------------------------------------------; ; Optionally call the routine that copi es initlialized data ; ; from program memory to data memory. ; ;------------------------------------------------------------; #IFDEF USE_INITDATA call copy_init_data #ENDIF ;------------------------------------------------------------; ; Set up the stack for use with functio n arguments and local ; ; (auto) variables. ; ;------------------------------------------------------------; _setup_stack 00c7 ba00 MOVLR 0x0 BANKSEL _stack ;Switch to bank where the stack pointer is 00c8 b022 MOVLW 0x22 movlw _stack+2 ;Store the adre ss of the stack pointer + 2 00c9 0120 MOVWF 0x20 movwf _stack ;Into the stack pointer ;------------------------------------------------------------; ; Branch to main() in the C program ; ;------------------------------------------------------------; 00ca c0c2 GOTO 0xc2 goto main END