The Shop > Electronics & IC Programing

EasyPIC-6 Development Board by MikroElectronica - Take"2"

<< < (6/14) > >>

raynerd:
I started to drown very quickly when I was trying to setup the PIC, I suppose that is why I`m suggesting use the examples.

Like Kwackers said try an LED code.

Load up the LED curtain MikroC example and then you know that all the setup is correct to allow the LEDs to come on (i.e outputs set)

Then go down to the main code - delete it all and type in something like:

void main ()      // <-- this should already be in the example code
{
while (1)     // Loops the code because 1 is always true so keep cycling through it!
{
PORTC.b1 = 1;    // turns on PORTC  bit 1 = so the LED should come on
delay_ms (1000);   // delay a second
PORTC.b1 = 0;     // the LED will go off
}
}

I think that should work...??

Then like Kwackers said, try and get two to flash and that sort of stuff. Then I tried to make 1 of 6 flash at random so that I had a dice ... etc

Chris

Then you should have a flashing LED!!

kwackers:
Sorry Chris, there's a bug in it...

you turn the led on,
wait one second
turn the led off
go back to the beginning.

See the problem?
The time take to go back to the beginning is in the order of a microsecond so the led won't be off for very long...

You can either add an extra 'off' delay after turning it off,
or
if you're happy with the on and off times being equal simply 'invert' the state of the bit
eg

--- Code: ---while (1)
{
    PORTC.b1 = !PORTC.b1;  // ! means 'not' i.e inverts the bit
    delay_ms(1000);
}

--- End code ---

(shorter too)

raynerd:
Yep...see that now :D

Which is why the EasyPIC is so good - me being a numpty would have loaded that to the PIC and then found it didn`t work! :D

void main ()      // <-- this should already be in the example code
{
while (1)     // Loops the code because 1 is always true so keep cycling through it!
{
PORTC.b1 = 1;    // turns on PORTC  bit 1 = so the LED should come on
delay_ms (1000);   // delay a second
PORTC.b1 = 0;     // the LED will go off
delay_ms(1000) // EDIT !!! EXTRA DELAY ADDED!
}
}

j45on:
Chris you think you are a numpty I managed to order completely the wrong book I ordered programming microcontrolers in assembly instead of C  :lol: that makes me a propper numpty  :doh:
I shall try your bit of code later

j45on:
I think I have broke it  :scratch:
I plugged in the board and switched it on and it was running the led curtain code from the library
I started a new project and copy n pasted the code above in and hit the build and program button
now I have nothing so I tried programing the curtain code nothing again so I tried the led blink and the 2x16 lcd one nothing works now
I have not changed any jumpers or switches since I bought it
The power,usb and pgr/icd leds sugest something is going on
I have tried it with and without the lcd,reset it removed and replaced the pic and still nothing  :zap: what have I done ?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version