C ++ help me

Discussion in 'Meet and Greet' started by cuitesun, Sep 24, 2010.

  1. cuitesun

    cuitesun New Member

    Joined:
    Sep 24, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone i am suppose to make a LED light up using c+ and i am stuck at it.
    I am using PIC16C745 ,i need to put this code in using MPLAB. But i tried to put my code in and still doesn't light up at all when i press the switch it got no reaction ):
    is alreadly been weeks i am stuck here. Any kind soul to guide me ^^ would be greatly appreciated .I am using 6mhz crystal.

    below is my code :
    Code:
    #include <htc.h>
    #include "delay.h"
     
     
     
     
    __CONFIG(WDTDIS & PWRTDIS & UNPROTECT & H4);
    /* Using Internal Clock of 8 Mhz */
    #define FOSC 8000000L
    /* The Delay Function */
    #define delay_us(x) { unsigned char us; \
            us = (x)/(12000000/FOSC)|1; \
            while(--us != 0) continue; }
    void delay_ms(unsigned int ms)
    {
      unsigned char i;
      do {
        i = 6;
        do {
          delay_us(164);
        } while(--i);
      } while(--ms);
    }
    void main(void)
    {
      TMR0 = 0x2F;         /* Select 6 Mhz internal clock */
      TRISA = 0x00;        /* Set All on PORTB as Output */
      ADCON1 = 0x00;           /* Set PORT ANS0 to ANS7 as Digital I/O */
      for(;;) {
        PORTA = 0x01;      /* Turn On Port RC0 */
        NOP();
        delay_ms(200);     /* Delay 200 ms */
        PORTA = 0x00;      /* Turn Off Port RC0 */
        NOP();
        delay_ms(200);     /* Delay 200 ms */
      }
    }
     
    Last edited by a moderator: Sep 24, 2010

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice