Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Meet and Greet (http://www.go4expert.com/community/meet-and-greet/)
-   -   C ++ help me (http://www.go4expert.com/community/c-help-me-t23404/)

cuitesun 24Sep2010 12:27

C ++ help me
 
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 */
  }
}



All times are GMT +5.5. The time now is 00:05.