Autor Tema: como paso este programa a un archivo HEX.  (Leído 1234 veces)

0 Usuarios y 2 Visitantes están viendo este tema.

Desconectado janic22

  • PIC10
  • *
  • Mensajes: 1
como paso este programa a un archivo HEX.
« en: 15 de Mayo de 2010, 14:44:32 »
HOLA SOY NUEVO Y NECESITO  SABER COMO PASO ESTE PROGRAMA Y SOFTWARE DE USAR .......


#include   <htc.h>
//#include   <pic12rf675.h>



 __CONFIG (PROTECT & BORDIS & MCLRDIS & PWRTDIS & WDTDIS & INTIO );

/*
// Bandgap Calibrations
#define BGHIGH      0x0x3FFF
#define BGLOW      0x0x0FFF
// Protection of data block
#define UNPROTECT   0x3FFF
#define CPD      0x3EFF
// Protection of program code
#define UNPROTECT   0x3FFF
#define PROTECT      0x3F7F
// Brown out detection enable
#define BOREN      0x3FFF
#define BORDIS      0x3FBF
// Master clear reset
#define MCLREN      0x3FFF
#define MCLRDIS      0x3FDF
// Power up timer enable
#define PWRTDIS      0x3FFF
#define PWRTEN      0x3FEF
// Watchdog timer enable
#define WDTEN      0x3FFF
#define WDTDIS      0x3FF7
// Oscillator configurations
#define RCCLK      0x3FFF
#define RCIO      0x3FFE
#define INTCLK      0x3FFD
#define INTIO      0x3FFC
#define EC      0x3FFB
#define HS      0x3FFA
#define XT      0x3FF9
#define LP      0x3FF8

*/

void main()
{   
      static unsigned char CONTEO; //cuenta los pulsos de reloj para switchear los leds
      static unsigned int RELOJ,RELOJ1,RELOJ2;
      static unsigned char CR;
      static unsigned char CG;
      static unsigned char CB;
      static unsigned char PRESUL;
      static unsigned int SUMA;
      static unsigned char MODO;
      static bit CAM,FCAM,DETE; //FCAM FLAG DE CAMBIO, SI ES 1 NO PUEDE CAMBIAR OTRA VEZ EL LAPSO, EN 1 SEG SE MODIFICA
      static unsigned char INDIC1;
      static unsigned int LAPSO; // lapso para cambio de color
     
   //************* INICIALIZACIÓN **************************************;

         //  76543210
   OPTION =  0b00000000;   // GPWU GPPU T0CS T0SE PSA PS2 PS1 PS0     
               /*
               bit 7    GPPU: GPIO Pull-up Enable bit
                  1 = GPIO pull-ups are disabled
                  0 = GPIO pull-ups are enabled by individual port latch values     
               bit 6    INTEDG: Interrupt Edge Select bit
                   1 = Interrupt on rising edge of GP2/INT pin
                   0 = Interrupt on falling edge of GP2/INT pin     
               bit 5    T0CS: TMR0 Clock Source Select bit     
                  1 = Transition on GP2/T0CKI pin
                  0 = Internal instruction cycle clock (CLKOUT)     
               bit 4 T0SE: Timer0 Source Edge Select bit
                  1 = Increment on high-to-low transition on T0CKI pin
                  0 = Increment on low-to-high transition on T0CKI pin
               bit 3 PSA: Prescaler Assignment bit
                  1 = Prescaler assigned to the WDT
                  0 = Prescaler assigned to Timer0
               bit 2-0 PS<2:0>: Prescaler Rate Select bits
               
               
                        TMR0      WDT
                  000      1 : 2**      1 : 1
                  001      1 : 4      1 : 2
                  010      1 : 8      1 : 4
                  011      1 : 16     1 : 8
                  100      1 : 32      1 : 16
                  101      1 : 64      1 : 32
                  110      1 : 128      1 : 64
                  111      1 : 256      1 : 128      */

   //          76543210
   TRISIO = 0b11111000;   
   
   //         76543210
   ANSEL = 0b00100100;
         
         /*   bit 7 Unimplemented: Read as ‘0’.
         bit 6-4 ADCS<2:0>: A/D Conversion Clock Select bits
            000 = FOSC/2
            001 = FOSC/8
            010 = FOSC/32
            x11 = FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
            100 = FOSC/4
            101 = FOSC/16
            110 = FOSC/64
         bit 3-0 ANS3:ANS0: Analog Select bits
         (Between analog or digital function on pins AN<3:0>, respectively.)
         1 = Analog input; pin is assigned as analog input(1)
         0 = Digital I/O; pin is assigned to port or special functionj, m
         
         */

   //       76543210
   ADCON0=0b00001001; //No se puede poner operativo en el mismo momento que se da orden de conversion
      /*   bit 7 ADFM: A/D Result Formed Select bit
            1 = Right justified
            0 = Left justified
         bit 6 VCFG: Voltage Reference bit
            1 = VREF pin
            0 = VDD
            bit 5-4 Unimplemented: Read as zero
         bit 3-2 CHS1:CHS0: Analog Channel Select bits
            00 = Channel 00 (AN0)
            01 = Channel 01 (AN1)
            10 = Channel 02 (AN2)
            11 = Channel 03 (AN3)
         bit 1 GO/DONE: A/D Conversion Status bit
            1 = A/D conversion cycle in progress. Setting this bit starts an A/D conversion cycle.
            This bit is automatically cleared by hardware when the A/D conversion has completed.
            0 = A/D conversion completed/not in progress
         bit 0 ADON: A/D Conversion STATUS bit
            1 = A/D converter module is operating
            0 = A/D converter is shut-off and consumes no operating current*/
                       

   GPIO=0;
   ADON=1;
   INTCON=0;
   MODO=0;
   DETE=0;
   
   CG=80;
   CB=0;
   CR=0;
   LAPSO=1000; // 1 SEG = 1000 mSeg
   
   
   //************* FIN INICIALIZACIÓN **************************************;



   while(1)
   {


     
     
      if (TMR0>101)   
      {   
     
         //boton
         if ((GPIO & 32)== 0)
         {
            if (FCAM==0)
            {
               FCAM=1;
               RELOJ1=0;
               if (LAPSO==1000)
               {
                  LAPSO=3000;
               }
               else if(LAPSO==3000)
               {
                  LAPSO = 10000;
               }   
               else if(LAPSO==10000)
               {
                  LAPSO = 20000;
               }   
               else if(LAPSO==20000)
               {
                  LAPSO = 1000;
               }
            }   
         }
         
         CONTEO++;
         if (CONTEO==81) {CONTEO=0;}
         
   
            INDIC1=0;
             if (CG>CONTEO)
                {INDIC1 = INDIC1+2; }
             if (CB>CONTEO)
                {INDIC1 = INDIC1+4; }
             if (CR>CONTEO)
                {INDIC1 = INDIC1+1; }
           
            GPIO=INDIC1;
           
     
         TMR0=0;
         
         RELOJ++;
         
         if (RELOJ>LAPSO)  // Ventana de lapso de tiempo para el cambio
         {
            RELOJ=0;
           
            if (DETE==1)
            {
               RELOJ2++;
               if (RELOJ2>80)
               {
                  DETE=0;   
               }   
            }
            else
            {
               CAM=1;
               RELOJ2=0;
            }
         }   
         
         
         
         RELOJ1++;
         if (RELOJ1>1000) 
         {
            RELOJ1=0;
            FCAM=0;
         }   
      }


   
   if (CAM==1)   
   {
      //CLRWDT();
         
      if (MODO==0)//CR=0
      {
         CR=0;
         CG=CG--;
         CB=CB++;
         if (CB==80)
         {
            MODO++;
            CG=0;
            DETE=1;
         }
      }
     
      else if (MODO==1)//CG=0
      {
         CG=0;
         CR=CR++;
         CB=CB--;
         if (CR==80)
         {
            MODO++;
            CB=0;
            DETE=1;
         }
      }
     
      else if (MODO==2)//CB=0
      {
         CB=0;
         CG=CG++;
         CR=CR--;
         if (CG==80)
         {
            MODO=0;
            CR=0;
            DETE=1;
         }
      }
   
   CAM=0;   
   }   

   }   
}

Desconectado MLO__

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 4581
Re: como paso este programa a un archivo HEX.
« Respuesta #1 en: 15 de Mayo de 2010, 15:28:05 »
Creo que es HiTech .......
El papel lo aguanta todo


 

anything