Delays!?

Questions and Comments on All Projects
Allibow
Newbie Pyro
Posts: 3
Joined: Sun Jun 07, 2009 8:36 pm

Delays!?

Postby Allibow » Sun Jun 07, 2009 9:07 pm

hello im having som problems, i have just started to program pic whit C

i have sucsessed to toggle the output for the LED on RB0 im using 18F4431

but when i try make it blinking it doesnt want to

i have tryed both delay_ms and delay_us

whit delay_us it starts to blink but its very random not as specified ....



Code: Select all

#include <18f4431.h>

#device *=16 //activate 16-bit

// circuit checksum as ID
#ID CHECKSUM

// zero ram registers
#ZERO_RAM

// clock freq, (10mhz crystal)
#use DELAY(CLOCK=40000000)

// I/O handling
//
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)

//ports to fileregister
#BYTE PORTD = 0xF83
#BYTE PORTC = 0xF82
#BYTE PORTB = 0xF81
#BYTE PORTA = 0xF80

void main(void)

{

        int iCount=0;

// PORTA all input 7pins
        SET_TRIS_A(0x7F); // 0111 1111 (1 is IN)

// PORTB all output 8pins
        SET_TRIS_B(0x00); // 0000 0000 (0 is out)

// PORTC declared output
// bit7 (RX) serial in serial port
        SET_TRIS_C(0x80);//1000 0000
      SET_TRIS_D(0xff);

// do while

        do{


            

            DELAY_US(500);
            BIT_SET(PORTB,0);
            DELAY_US(500);
            BIT_CLEAR(PORTB,0);
            
            
            

        }while(1);
}// END

Allibow
Newbie Pyro
Posts: 3
Joined: Sun Jun 07, 2009 8:36 pm

Postby Allibow » Tue Jun 09, 2009 8:18 am

turns out there was something wrong whit my crystal, it works when i change setting to HS instead of HS-pll


Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest