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.

PICKit 2 16F690 programming

Status
Not open for further replies.

neillsun

Junior Member level 2
Joined
Jul 12, 2007
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
London, UK
Activity points
1,442
16f690 programming

I have recently bought a PICKit 2. ASM may as well be greek to me at this stage. I understand the logic behind it, but have yet to learn the commands and registers, so I'm not too sure what I am looking at.

No problem, because I know C better, though not really well enough. I found a 'Hello World' program for the '690 written in C and understand that and can set my own LED patterns on the Low Pin Count Demo Board. Now what I want to know is how to read the input - looks like RA3 (the demo board's push button is connected to this pin).

Thanks,
Neill.

Hopefully I don't have to look in the trach for replies to this post!! ;-)
 

pickit 2 16f690

Code:
if(RA3 == 1){
  do_something;
  }
else{
  do_something_else;
  }
 

programming 16f690

Thanks, btbass.

Didn't work though!

This is what I have:

Code:
if(RA3 == 1){ 
  RC0=0;
  RC1=0;
  RC2=0;
  RC3=0; 
  } 
else{ 
  RC0=1;
  RC1=1;
  RC2=1;
  RC3=1;
  }

I'm starting to think the input may not be RA3 ('though that is what is printed on the PCB).

Would I need to set the pin as an input?

Thanks,
Neill.
 

asm 16f690

The micro resets with the ports as inputs. Maybe you need to set the others as outputs, normally you set TRISC bits to an 0 for output or a 1 for input.
Easy to remember 0 = Output, 1 = Input.
 

16f690

OK, the program starts with TRISC0=0 thru TRISC3=0. These, I assume are RC0 thru RC3, used to drive the LEDS.

So I should then set TRISA3 to 1 to make it an input?

Will give it a try.

N.
 

16f690 status bank

neillsun said:
Now what I want to know is how to read the input - looks like RA3 (the demo board's push button is connected to this pin).

in asm it would be more easy

1. select Bank where PORTA register is located, then do:

Code:
btfss      PORTA,2   ;check bit 2 in PORTA register,if set ignore next instruction
nop
goto      SomeWhere

Added after 12 minutes:

neillsun said:
So I should then set TRISA3 to 1 to make it an input?

again in asm u would select then bank where PORTC register located, then:

Code:
bsf      PORTC,0      ; turn on LED number 1
bsf      PORTC,3      ; turn on LED number 4

if u are newbie, then begin with asm!

look in device datasheet to find out how to select memory banks, every chip has its own architecture of memory, but mostly they are same (for example PIC16F84 has only 2 banks)

STATUS register and its RP0 and RP1 bits are used to select banks

and TRISB, TRISA, TRISC registers are used to define the direction of PORTA,PORTB,PORTC ports.. if bits in TRISA,TRISB,TRISC are set to 1 pins are defined as input, if 0 for output.

Added after 1 minutes:

check this simple URL for beginning:
**broken link removed**
 

16f690 resets

Thanks, BlackOps. I have had a look at Mike Stracey's site before. (and book marked it for reference!).

I know that ASM isn't that hard once you know the structure... but I would feel more comfortable with C.

Crikey... I know I read something about the different banks, guess I forgot about it. Would I need to switch banks then read the value of the input pin (RA3), then switch banks back to write to the outputs (RC0-3 in this case)?

Thanks,
Neill.
 

pickit2 switch

no u dont need, u check bits of PORTA, then write to the PORTB or whatever on ur chip
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top