Author Topic: pickit4 xc8 and 16f628A and nothing happens.  (Read 1496 times)

0 Members and 1 Guest are viewing this topic.

Offline matiseTopic starter

  • Contributor
  • Posts: 28
pickit4 xc8 and 16f628A and nothing happens.
« on: August 13, 2018, 01:31:13 pm »
Hi.

Can someone give me a hint?

im programming this pic16f628A and build and make works fine.

(pickit 4)

it says its all succesfull.

But that darn led just dont blink.

ive tried, like you see in my code, even simplier to just give RB5 5v and no delays.

Nothing.

ive tried another pic but nothing.

What am i missing?

I know i connect it right + - and RB5 out to led.

i have tested led and it works...

hmmm, i cant see anything wrong.


#include <pic16f628A.h>
#include <xc.h>
#pragma config FOSC = INTOSCIO
#pragma config WDTE = OFF        // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF   
#pragma config MCLRE = ON      // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
#pragma config BOREN = ON       // Brown-out Detect Enable bit (BOD enabled)
#pragma config LVP = OFF        // Low-Voltage Programming Enable bit (RB4/PGM pin has PGM function, low-voltage programming enabled)
#pragma config CPD = OFF       // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF 
#define _XTAL_FREQ 4000000

/*
 *
 */
int main(int argc, char** argv)
{
    TRISB = 0b00000000;
   
while(1)
    {
     
        PORTBbits.RB5 = 1;
        //__delay_ms(500);
        //PORTBbits.RB5 = 0;
        //__delay_ms(500);
    }
    return 0;
}
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: pickit4 xc8 and 16f628A and nothing happens.
« Reply #1 on: August 13, 2018, 03:10:59 pm »
Please, use code tags next time

I seem to remember that there are issues with IPE and probably also the IDE and some tools, where MCLR is not de-asserted after programming. You could try removing the MCLR connection after you program the pic

Quote
int main(int argc, char** argv)
just use
Code: [Select]
void main()
 

Offline matiseTopic starter

  • Contributor
  • Posts: 28
Re: pickit4 xc8 and 16f628A and nothing happens.
« Reply #2 on: August 14, 2018, 12:29:51 pm »
yes, it seems to be something with MCLR.
Thing are going in right direction.
tnx!
 

Offline towlerg

  • Contributor
  • Posts: 39
Re: pickit4 xc8 and 16f628A and nothing happens.
« Reply #3 on: August 15, 2018, 12:20:46 pm »
As you're not using LVP, you can turn MCLRE off.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: pickit4 xc8 and 16f628A and nothing happens.
« Reply #4 on: August 25, 2018, 03:41:01 am »
Please, use code tags next time

I seem to remember that there are issues with IPE and probably also the IDE and some tools, where MCLR is not de-asserted after programming. You could try removing the MCLR connection after you program the pic

Quote
int main(int argc, char** argv)
just use
Code: [Select]
void main()
While
Code: [Select]
int main(int argc, char** argv)is excessive for microcontrollers, if you used
Code: [Select]
void main()you will get yelled at by some compilers. The compromise should be:
Code: [Select]
int main(void)which is appropriate for this purpose and won't get you unwanted warnings.
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2155
  • Country: gb
Re: pickit4 xc8 and 16f628A and nothing happens.
« Reply #5 on: August 25, 2018, 11:11:38 am »
put a pullup resistor on MCLR.

my first pic circuit was unstable till i realised it had no internal pullup and was constantly resetting.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf