Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problems programing PIC 16f628A in C

Status
Not open for further replies.

rgc

Junior Member level 1
Joined
May 3, 2011
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,430
I wrote a very simple C program on MPLAB to set all ports to high on a PIC 16F628A, it built okay on HI-TECH C, no erros, and it was programmed to the chip using PicKit 3 flawlessly... But it doesn't work, the pins wont go high!

I tried it with multuple PIC's.

I use MPLAB 8.45 on windows 7 and HI-TECH 9.81 lite (which is supposed to support W7)

This is the code:

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <htc.h>
#include <pic16f628a.h>
 
__CONFIG(BOREN_ON & CP_OFF & PWRTE_ON & WDTE_OFF & LVP_OFF & MCLRE_ON);
 
void main(void){
    CMCON = 0x07; //Comparators off
    TRISB = 0b00000000; //All ports to output
    TRISA = 0x00;
    
 
    while (1){
        PORTB = PORTA = 0xFF;
    }
}



What have I done wrong? Should I pick another compiler?
 

Hi-Tech is a good compiler. You don't need to include the pic header file, thats included in the htc.h file.

It might be because you haven't configured the oscillator?
The default is external resistor capacitor oscillator.

__CONFIG(INTIO & BOREN_ON & CP_OFF & PWRTE_ON & WDTE_OFF & LVP_OFF & MCLRE_ON);
 
  • Like
Reactions: rgc

    rgc

    Points: 2
    Helpful Answer Positive Rating
Follow this steps
boren_on: Check your supply. Is it up to 5v.
Mclr: Is mclr voltage high and not above your vdd.
Osc: Oscillator config is not defined which default to rc mode.
 
  • Like
Reactions: rgc

    rgc

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top