Searching \ for ' [PIC}: Incredibly simple program works i' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Incredibly simple program works i'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] [PIC}: Incredibly simple program works i'
2001\08\06@004655 by Ed Troy

flavicon
face
In an effort to try to debug the program that I am having trouble with, I
have stripped it down to the very basic essentials. It is now a program
that should toggle some bits on and off depending on the value of bit RA4.
If RA4 is high, RD7 and RD6 should toggle from high to low. If RA4 is low,
then RD5 should toggle from high to low. (I know I typed RD5 in twice, but
that should not make any difference.) The program works fine in the
simulator (and I also know that the actual delay is a lot less than 1
millisecond...I just wanted to simplify the simulation). But, when I go to
the actual board, everything just sits at zero!! The clock signals look
fine, and the supply voltages are fine. I've tried several chips, so it is
not a bad chip. I've tried turning on and off the power up timer, and I've
turned off the watchdog timer. I've also turned off the brownout timer.
Usually, I have the master clear tied directly to the power supply, but
I've also tried tying it to 5 volts after the power supply is up and
running. Nothing seems to matter. The really strange thing is that the
simulation works fine, and I get no errors or warnings when I compile. I'm
obviously doing something VERY wrong, but I don't know what it is.

Ed
/*

This is the suspect c file

*/

#include    <pic.h>
#include <stdio.h>

void DelayMs(unsigned int cnt)
{
        unsigned i;
        i=6;
        while(i!=0)
        i--;
        while(cnt!=0)
        cnt--;
}


void Initialize_Ports()
        {
                TRISB=0x00; // set port b as outputs
                TRISD=0x00 ; // set port d as output
                TRISA=0x3F ; // set port a as inputs
                TRISC=0x00 ; // set port c as output
                PORTD=0x00 ; // initialize port D to zero
                PORTC=0x00 ; // initialize port C to zero
        }


main()
        {
        Initialize_Ports();
                RD3=1;
                RD2=1;
                RC6=1;
                DelayMs(2) ;
                RD4=1;
                RD2=0;
                RC7=1;
        while(1)  // loop forever
        {
                RC6=1;
                DelayMs(2) ;
                if (RA4 = 1)
                {
                        RD7=1;
                        RD6=1;
                        DelayMs(1);
                        RD7=0;
                        RD6=0;
                }
                else
                {
                        RD5=1;
                        RD5=1;
                        DelayMs(1);
                        RD5=0;
                        RD5=0;
                }

        }

}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\08\06@020253 by Salah Mohammed

flavicon
face
Dear Ed,

  It depends on the chip your are using...for example if it is PIC16F877
then there is some registers associated with PORTA...inorder to set up PORTA
in a specific configuation first you have to configure the associated
register(s),
for the chip above ADCON1 reg. is the associated reg. for example if you
want to configure RE2,RE1,RE0(from PORTE) as Digital I/O and RA1,RA0(from
PORTA) as analog Input then you need to set the ADCON1 reg. as follow:

ADCON1 = 0x04;

then here u can go with the TRISx

in the chip above PORTA pins by default configureg as analog input.

please refer to the DATA sheet of the chip and especially to the associated
reg(s). with each I/O PORT.

that was I know ...I hope it will help.
Regards
Mohammed

{Original Message removed}

2001\08\06@144606 by Heinz Czychun

flavicon
face
Hi Ed,


At 12:40 AM -0400 8/6/01, Ed Troy wrote:
>In an effort to try to debug the program that I am having trouble with, I
>have stripped it down to the very basic essentials.
.....<snip>....

I haven't programmed a PIC in C, so I'm probably off base but, I
don't see where the page bits are being set to access the TRIS
registers. The C compiler may handle this for you, I'm not sure.
It would certainly cause a lack of action on the board.


{Quote hidden}

.......

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...