CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with PIC16F13115 and a GPIO (SOLVED)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
AltPic8088



Joined: 12 Mar 2026
Posts: 2

View user's profile Send private message

Problem with PIC16F13115 and a GPIO (SOLVED)
PostPosted: Thu Mar 12, 2026 5:31 pm     Reply with quote

Good afternoon.

I need to migrate a small project to the PIC16F13115 from the PIC12F1840 that I am currently using.

The only problem I have in the entire migration is the RA5 output, which does not change state.

The code I am using to test is the following:

Code:

#INCLUDE <16F13115.h>

#FUSES WDT                    // Utilizamos el perro guardián.
#FUSES PUT_64MS               // Habilita el power uP timer en 64ms.
#FUSES NOMCLR                 // Utilizamos el pin MCLR como E/S.
#FUSES PROTECT                // Proteje el código del microcontrolador.
#FUSES NOBROWNOUT             // No hay reset por bajo voltaje.     
#FUSES NOCLKOUT               // Utiliza los pines de clk como E/S.           
#FUSES FCMEN                  // Monitor de falla de clock.                 
#FUSES NOWRT                  // No hay protección de registros especiales.
#FUSES STVREN                 // Si la pila se llena, generará un reset.     
#FUSES NODEBUG                // No utilizaremos código de debug.
#FUSES WDT2048                // Utilizamos el perro guardián cada 2 segundos.
#FUSES NOLVP                  // No utilizaremos programación a bajo voltaje.
#FUSES NOBOOTBLOCK            // No deja espacio para el booteo.

#USE delay (Clock = 32000000,restart_wdt) // Reloj = 32Mhz.


//------------------------------------------------
// Inicialización
//------------------------------------------------

void Inicializacion(void)
{

   setup_oscillator(OSC_HFINTRC_32MHZ);

   output_a(0x00);
   delay_ms(100);
   setup_wdt(WDT_2S);
}

//------------------------------------------------
// MAIN
//------------------------------------------------

void main()
{

Inicializacion();
setup_adc_ports(NO_ANALOGS);

   while(TRUE) {
      output_high(PIN_A5);
      delay_ms(500);
      output_low(PIN_A5);
      delay_ms(500);
      restart_wdt();
   }

}


Does anyone have an idea where I might be going wrong? I checked the datasheet, consulted AI, etc., but I still can’t figure it out.

I thought it might be a CCS error, but the affected registers shown in the assembly file seem to be correct.

Best regards!


Last edited by AltPic8088 on Thu Mar 12, 2026 9:04 pm; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9627
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 12, 2026 6:53 pm     Reply with quote

don't use that PIC but 2 things come up

1) RA5 is a pin selectable pin.. so you might have to actually select it....
there's a 'sticky' up top about 'how to use'...

2) get rid of the WDT ! you really shouldn't use/enable it until your program is 100% tested and ready for sale. ONLY then should you enable the WDT ,after having calculating the correct WDT 'timeout period'.

3) delete the 'protect' fuse

I'm sure others who use the PIC will reply soon....
AltPic8088



Joined: 12 Mar 2026
Posts: 2

View user's profile Send private message

PostPosted: Thu Mar 12, 2026 9:02 pm     Reply with quote

Thank you very much for the response, Temtronic.

The solution was to add the following configuration lines:

Code:

#FUSES RSTOSC_HFINTRC_32MHZ   // Oscilador interno con PLL a 32Mhz.
#FUSES NOCLKOUT               
#FUSES NOEXTOSC               // No utilizamos el oscilador externo.


Greetings!
temtronic



Joined: 01 Jul 2010
Posts: 9627
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 13, 2026 5:52 am     Reply with quote

Great to see 'SOLVED' in a post !
Ttelmah



Joined: 11 Mar 2010
Posts: 20051

View user's profile Send private message

PostPosted: Fri Mar 13, 2026 6:58 am     Reply with quote

Or use the correct clock setup:
Code:

#USE delay (INTERNAL = 32000000,restart_wdt) // Reloj = 32Mhz.


Your original setup was saying the clock was 32MHz, but not telling the
complex 'where' to get this from. Setting this with the fuses is more
complex (especially on a lot of the later chips), while just specifying it in
the delay line, tells the compiler what fuses it has to set to get this.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group