CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

I/O on 16F819

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
BMaxwell



Joined: 07 May 2004
Posts: 20

View user's profile Send private message

I/O on 16F819
PostPosted: Tue Sep 21, 2004 4:41 pm     Reply with quote

Im getting perfect I/O on PINS B0,B1,B2 but on pin B3 its messing up big time. I tried to turn off low voltage programming. I also tried changing pins but it either resets the PIC or gives eronious data. These pins are tied through 10k to ground. I am using the input(PIN_B3) command to check for a change. Is there a better command than this. These go from 0 to 5V when the Fire Alarm goes off. Thanks in advance guys. Your the best community techies Ive seen.
Thanks Bryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 21, 2004 4:47 pm     Reply with quote

Quote:
I'm getting perfect I/O on PINS B0,B1,B2 but on pin B3 its messing up big time.

What specifically is the problem with reading Pin B3.
You said "it's messing up big time". In what way ?

Quote:
I also tried changing pins but it either resets the PIC or gives eronious data.

I'm not sure what you mean by this. What if you use Pin B4 ?
Does it work ?

If you are using the ICD2, it uses pins B6 and B7. If you tried to
use one of those pins, that might explain some of your problems.

What programmer are you using ? Can you guarantee that you
are turning off LVP mode ? Can you tell your programmer to read
the PIC, and see what it says the Config Bits are set to ?
BMaxwell



Joined: 07 May 2004
Posts: 20

View user's profile Send private message

Pin_B3 either resets, or does not read at all when it goes h
PostPosted: Tue Sep 21, 2004 5:01 pm     Reply with quote

When its connected to PIN_B3 it doesnt read the high at all and does not update until the PIN goes low again. Its like it cause a halt or something.
I changed the PIn to B4 and A2 however these did not work either. I talked to a Microchip guy and he said write to adcon1(6) so i tried set_tris_b(0x0F) with #use fast_io and still get the same result. Not using Icd2. Im using a Chipmax from ee tools. I cant be sure it is turning off LVP. It does have a box for it and I change it to I/O for that PIN. It seems to read in the fuses that "PGM is Digital I/O, HV on MClR" this line is in the box for LVP. Thanks in advance PCM. Bryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 21, 2004 5:45 pm     Reply with quote

Quote:
When its connected to PIN_B3 it doesnt read the high at all and does not update until the PIN goes low again.

This sounds like the pin is configured for LVP mode.

I looked at the eetools.com download page.
http://www.eetools.com/download.asp
The latest update for the Chipmax was in December 2002.
That's not good. It means they don't fix bugs, and there are
always going to be some. I suspect they are not programming
the LVP fuse properly. (ie., you can't disable LVP mode).

Assuming you can't get another programmer, my suggestion is to put
a 10K pull-down resistor (to ground) on Pin B3, and don't use that pin.

Then use Pin B4. It should work. As long as pin B3 is pulled down
to ground, then the PIC will not go into LVP mode. (ie., it won't lock up).

To test if you can make pin B4 work as an input, try this simple test
program. It reads pin B4 continuously, and outputs the value it read
onto pin B0. So if you had a push-button on Pin B4, and a LED on
Pin B0, then when you press the button the LED should turn on.
(or go off, depending on how you have the LED wired).
If you have an oscilloscope you can leave off the LED and just look
at pin B0 to see if it follows pin B4. Note that I have port B pullups
turned on, so the idle state for pin B4 is a high level. When the
pushbutton is pressed, pin B4 will go to ground. (One side of my
pushbutton is connected to pin B4, and the other side to ground).
Code:

#include <16F819.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT 
#use delay(clock = 4000000)
//==================
void main()
{
char value;

port_b_pullups(TRUE);

while(1)
  {
   value = input(PIN_B4);
   output_bit(PIN_B0, value);
  }

while(1);
}
BMaxwell



Joined: 07 May 2004
Posts: 20

View user's profile Send private message

ROFL - Im an idiot
PostPosted: Wed Sep 22, 2004 12:33 pm     Reply with quote

Try this line and dont laugh to much PCM. if(input(PIN_B3==1))
ROFL suppose to be if(input(PIN_B3)==1) woops. No wonder it hanged. Lol talk about a mistake. Anyways thanks for the help, you are the man.
Bryan
Suma
Guest







I don't get it
PostPosted: Thu Mar 02, 2006 4:27 am     Reply with quote

From 1 week ago I have a IDC2 to program my PIC, 16f819.
I have never used a PIC before, and I have some knowledge in rpogramming with C.
This is my last program, I am trying to make flash one pin of the PIC, but I don't understand why it doesn't work.
Maybe you can give me a hand. If you know where I could find easy examples, etc.
This is my program:
Code:

#include "E:\Documents and ..\pogramas C compiler\prueba3\prueba3.h"
  #include <stdio.h>
  #include <stddef.h>
  #include <stdlib.h>


void main() {

   port_b_pullups(TRUE);
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_counters(RTCC_INTERNAL,WDT_18MS);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   
   while(true){
               output_high(PIN_A1); //se activa el pin
               delay_ms(1000);       //esperamos un segundo
               output_low(PIN_A1);    //lo bajamos
               delay_ms(1000);         //esperamos otro poquito
               }


}



And this my .h:
Code:


#include <16F819.h>
#device adc=8
#use delay(clock=4000000)
#fuses INTRC_IO,PUT,WDT



Thanks you for helping me.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 02, 2006 1:01 pm     Reply with quote

Change the prueba3.h file to this:
Code:
#include <16F819.h>
#device adc=8
#fuses INTRC_IO, PUT, NOWDT, NOLVP
#use delay(clock=4000000)

Notice the following things about the code above:

1. The Watchdog Timer is disabled by using NOWDT.

2. Low Voltage Programming mode is disabled by using NOLVP.

3. Also notice that I have put the #use delay() statement below
the #fuses statement. The order of the statements is important.
When it's done in the order above, the compiler will insert code to
setup the oscillator properly for INTRC_IO and 4 MHz operation.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group