cembeddedpicmicrochip

Requesting a simple code for PIC10F200 using MPLAB XC8 Compiler


I can't program this microchip (using a PicKit5, should be no issues), either because its too old or I'm lacking a lot of knowledge.

So the program gets written correctly with no errors, but when I'm hooking up the microchip, making sure it gets a steady 5V from my source(Arduino Uno, I use the VDD(+) and VSS(-) for getting the microchip powered, if it's wrong please make a note), but the thing is, it does not light up anything, I have 4LEDs for each output just in case its a 1ms flash on any but there is none.

I just want to make one of the outputs to send a signal for 20s(for example) and than wait 20s and repeat the cycle (in my situation I chose GP1).

#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
#pragma config WDTE = OFF       // Watchdog Timer (WDT disabled)
#pragma config CP = OFF         // Code Protect (Code protection off)
#pragma config MCLRE = OFF      // Master Clear Enable (GP3/MCLR pin fuction is digital I/O, MCLR internally tied to VDD)

#define _XTAL_FREQ 4000000

void main()
{
    while (1)
        TRISGPIO = 0b00000000;
        // GPIO = 0b00000000; 
        __delay_ms(100);
        GPIObits.GP1 = 1;
        __delay_ms(100);
        GPIObits.GP1 = 0;
}

This is the last attempt of my code. Not the brightest.

The circuit diagram


Solution

  • put { and } to define your while (1) loop.

    void main()
    {
        while (1)
        {
            TRISGPIO = 0b00000000;
            // GPIO = 0b00000000; 
            __delay_ms(100);
            GPIObits.GP1 = 1;
            __delay_ms(100);
            GPIObits.GP1 = 0;
        }
    }
    

    Without them your code only do:

        while (1)
            TRISGPIO = 0b00000000;