Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC 10F220...I have no clue what so ever of how it goes

Status
Not open for further replies.

gutisie

Junior Member level 1
Joined
Apr 26, 2010
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,426
PIC 10F220

Dear All;

My name is GUTI, I have started programing PICS, I find them interesting, but I have very little understanding of them.
I have some pdfs that are very help ful but I am a bit stuck at the moment.
I am able to blink the led, thats no problem. But now I am trying to do som debouncing code to count the number of time a ir barrier is broken by the passing object.
I have the pic 10f220 conected in port gp0 the ir emitter from an old ball mouse, and on port gp3 the ir receiver. So thats the ir barrier.
On port gp1 I have a mosfet gate conected. This mosfet will drive a dc motor.
The idea is when it counts 3 objects (3 times the ir barrier is broken), the gp1 goes low for 1 second. And then starts again.
More or less this is my code at the moment, but I have no clue what so ever of how it goes. :cry:
I am using ccs pcb compiler with mplab 8.5
Any help much appreciated.
Best regards.
CODE:

#include <10F220.h>
#define GP0 PIN_B0
#define GP1 PIN_B1
#define GP2 PIN_B2
#define GP3 PIN_B3

#use delay (clock=4000000) //frecuencia

//for some reason fuses dont work, so i delete this line
#fuses MCLR,NOPROTECT,NOWDT,INTRC


void main()
{
while (TRUE) {
output_high(GP0); //ir led on

output_high(GP1); //mosfet on

And i dont know how to finish...now i should count upto 3 interrupts and then make low GP1, for 1 second and repeat loop, but I dont know how....
Any help much appreciated.
Thanks.
 

PIC 10F220

sound like you should just pick up a book on programming in general and finish reading it / practicing it on the mcu.

at this point, anyone giving you a piece of working code is doing you a huge disfavor.
 

Re: PIC 10F220

I am having problems with programing....i am using pickit2 and it reads but it has some code in, as is not blank according to software, plus it is giving code protection.
How can i unprotected using what?...anybody?
Thanks.
Best regards.
 

Hello guitsi,
Even if u get code for ur program...I guess the project still wont work...
Reason is the IR Transmitter/Receiver(assuming an IR LED), couldnt be just driven by applying a high logic to it...It needs to be driven at a particular frequency, typically 38Khz...but still if u want...Here is basic idea of implementing it...

void main(){
unsigned char x=0;

while(1){
while(x<3){
if(barrier detected) //ie (gp3==1) or 0 i dunt kno exactly what it goes
{
(code for switch debouncing...)
x++;
}
else
continue;
}
gp1=1;
delay_ms(1000);
gp1=0;
}
}

This is simply a rough program which demonstrates counter using switch...u need to work on it...& be clear about the working of IR tras/rec u are using...
(sorry for improper writing format, browsing through smartphone)...

Regards.
Sidy.
 

thanks a lot for your response guys.
But the problem i have is with the chip not the software, the thing is that i can not upload to the chip the software cause the pickit2 wont letme write it in the pic, since it says that it is code protected.
I can not erase it, I have look datasheet and it explains something but i dont understand it very well.
If any body could explain it, i will be very grateful.
Best regards.
GUTI.
 

@guitsie - Download this file...It is Pickit2 Programmer/Debugger User's Guide - ww1.microchip.com/downloads/en/DeviceDoc/51553E.pdf - At page no. 24 there is a note after the Topic "Enable code protect" This note tells how to disable the code protect...Hope it helps....Regards.
 

Thanks Sidi, but still it dose not work....nevertheless I have tried with my other pic 16f722 but, I dont know this pic and dont know how to convert the code to use with another compiler....I have the universal toolsuite in mplab with that compiler, but...dont know how to transfer my code to make it for the 16f722....
Thanks for all your help.
Best regards.
 

could anybody tell me what are the corret processesor setting for the 16f722?, i meant, EXT RESET, NO CODE PROTECT, NO BROWNOUT DETECT, NO WATCHDOG, POWERUP TIMER ENABLED, 16MHz INT CLOCK
I am using Mplab universal toolsuite, and my actual configuration is:

__CONFIG(MCLREN & UNPROTECT & BORDIS & WDTDIS & PWRTEN &INTRC);

code:
#include <htc.h>
#include "delay.c"
#define LED RB7

void main (void)
{
TRISB = 0;

while(1)
{
LED = 1;
for(unsigned int i=0;i<30000;i+=1);

LED = 0;
for(unsigned int i=0;i<30000;i+=1);
}
}

but it isnt blinking at all, so something is wrong....but what...it compiles ok.....this is a bit confusing...
Any help?
Thanks.
 

thanks, i have tried with other ports, and nothing happens.

I dont know....any way...
Does anybody knows the OSCAL value for PIC 12C509A?
Thanks.
 

i have tried with other ports, and nothing happens.

if you don't read the datasheet, keep trying different ports just keeps wasting your time.

Does anybody knows the OSCAL value for PIC 12C509A?

if you read the datasheet, you will know that there is not ONE OSCCAL value for the chip: each of them may have a unique value.

Again, read the datasheet.
 

Hi, thanks i did read the datasheet, and nothing.
But I bought another pic and it works, so what i think is that the internal oscillator was not working properlly.
Nevertheless thanks.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top