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 support@ccsinfo.com

i need help on LED programming
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
love_hina
Guest







re re
PostPosted: Wed Jul 28, 2004 8:50 pm     Reply with quote

btw, why is there 2 different pic?

#include <16F877.h> ) 2 diff pic??
}
#include <18F452.h> )

should i change them both to pic18f252?? cus i'm using them?sorry..keep botherin u guys..cus i really know nothin about css and i have to do a project on it....
thanz a lot..
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Jul 29, 2004 7:10 am     Reply with quote

This section:

#if defined(__PCM__)
#include <16F877.h>

will only include the 16F877 header if the token __PCM__ is defined, and it is only defined if you are using the PCM compiler. The PCH compiler will ignore these lines and instead use the 18F header. It is a way to use the same code for multiple chips.
_________________
The search for better is endless. Instead simply find very good and get the job done.
love_hina
Guest







re
PostPosted: Thu Jul 29, 2004 6:42 pm     Reply with quote

erm..so does it means tt i dun include this section or do i put 2 as the same? sorry...i'm completely new to this css so i dunno...
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Enough of the cat and mouse...
PostPosted: Thu Jul 29, 2004 8:06 pm     Reply with quote

OK, look, this is getting ridiculous, just use the code below. Since we know zero about what is connected to what it's likely a bats chance in hell it is going to work but here it is. You seem to be determined to do nothing here to help this situation much less read anything and have a clue what you are doing. By the way it is CCS not CSS

Code:

#include <18F252.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)


void main() {

   do {
      delay_ms(1000);
      output_high(PIN_A0);
      delay_ms(1000);
      output_low(PIN_A0);
   } while (TRUE);
}

love_hina
Guest







what cat and mouse?
PostPosted: Thu Jul 29, 2004 8:47 pm     Reply with quote

well, i apologise if i caused trouble but if i know anythin about this, i wont be posting here..i jus wan some help and i guess help is voluntered..thanz for those that helped me..i'm very grateful even though i keep asking questions.but if u wish to help me,i can understand but i guess the least u could do is put me down with ur words... Crying or Very sad
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Jul 30, 2004 6:55 am     Reply with quote

You are misunderstanding my message. My intention was not to put you down but to make a point.

At the outset yoiu stated this was a school project. We have no problem with helping anyone who comes here including you IF they show a reasonable effort to work the problem out themselves. I (and I am sure most here) have been in the situation of not knowing where to start so we understand that much.

The project you have outlined is not simple or one to be taken lightly, it will take a LOT of work and time to pull it off. I have seen some people here work for weeks and months trying to accomplish what you are trying to do.

To be able to help you first we need answers to all the following questions:.

1. State the version and type of CCS compiler (PCM, PCH or PCB) that you are working with. You have stated you will be using the 18F242 with MPLAB 6.40 but you MUST ALSO have the CCS C compiler.

2. Give us some kind of info as to what you have for hardwrae and where is is connected. For example: you say you have RJ45 and DB9 connectors. Why do you have both and what are they connected to on the PIC? If you dont know your hardwrae it is impossible to write software for it. Do you have a schematic?

3. Read the CCS C manual and spend time browsing this web site to learn how others have done it. Search on the keyword LED for a good start.

4. Don't expect us to write your code for you. After you have done your part, developed some code and posted it here we can try to help you. Most all the long time posters here have professional jobs and families that we maintain and can't be spending a lot of time doing other folks work for them.

5. The first code you posted wasn't even for this compiler which made it clear you had done very little research on CCS C. If you are using the C18 compiler we can't help you, you will have to go to the Micochip C18 forum for help.

Bottom line, most everyone here is willing to help someone who tries to help themselves and this also applies to you. I for one have nothing against you and truly hope you really learn CCS C and become a long time member of this board. One thing to remember is we are not mind readers and you have to provide the info we request or we cannot help you.

I am an engineer and instructor by profession so I enjoy teaching and helping my students. Howver, if they don't show any initiative then I also have no problem in letting them fail.

I for one wish you the best. If you can answer the above questions maybe we can get restarted on the "right foot".

Best Regards,
Dave


Last edited by dyeatman on Fri Jul 30, 2004 7:00 am; edited 1 time in total
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Jul 30, 2004 6:58 am     Reply with quote

It would do you good to read the CCS manual cover to cover. It doesn't take that long and will give you a wealth of information. You should also have a good C book like Kernighan & Ritchie (ISBN 0-13-110362-8) and the Microchip data sheet for the chip you are using.
You learn a lot more when you research and answer your own questions.
_________________
The search for better is endless. Instead simply find very good and get the job done.
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Sun Aug 01, 2004 12:08 am     Reply with quote

LEDs are usually tied directly to ports, so making a port go High or Low will turn them ON or OFF.


thanks
arun
Jeprox
Guest







PostPosted: Mon Aug 02, 2004 11:07 pm     Reply with quote

I don't want to make a guess here. But, I would assume that the DB9 is for the serial comm, and the RJ45 is for the ICD to program the PIC.

Once you have set up the port just start with dyeatman's code to get a feel of playing with LEDs.

The VB program you are using, I think, is a simple one which only sends a particular command (message). The PIC receives this message through serial and interprets it. If this is the case, put a Switch Case statement, which will test the received message.
love_hina
Guest







re re
PostPosted: Tue Aug 03, 2004 2:59 am     Reply with quote

yap..you got it right..i'm now writing the program now..dun think it's right but still working hard..i didn't paste it here as it is sort of crap...sorry to all...


#include <p18f252.h>
#include <delays.h>

#use rs232(baud=9600, XMIT=PIN_A0, RCV=PIN_A1, PARITY=N, BITS=8)

#define NUMBER_OF_LEDS 7

void main (void)
{
PORTA = 1; //configure PORTA and TRISA for input
TRISA = 255;

PORTB = 0; //configure PORTB and TRISB for input
TRISB = 0;

PORTC = 1; //configure PORTC and TRISC for input
TRISC = 255;

if(PORTA==0x00) //no input
{
TRISB=0x00 //no LED light up

}
else
{
TRISB=PORTA //takes the input value from port A

}
else if
{

PORTC = 1;
PORTB = 1;

}



i got a bit here and there... i have a push button at port c, pushing it allows all LED to light up... i have set PORTB as output and PORTA as input for the LED....

pls dun get mad at lookin at my code..i really did my best...
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

PLease give us some info or we cannot help
PostPosted: Tue Aug 03, 2004 11:03 am     Reply with quote

We understand you are trying but you MUST answer our questions or we cannot help....

So, one more time, lets get some info here:

1. Are you going to answer the questions I asked you earlier? We need those answers!

2. What version and type of compiler are you using?

3. What PIN is the pushbutton switch connected? What is the other end of the switch tied to?

4. You cannot have 7 LEDs connected to Port A there are only 6 connections so I would double check and determine where/how they are really connected. PLease tell us what PINS they are connected to.

5. How are the LEDS connected? One end to 5VDC? What is the other end tied to?

6. Did you design the board or is it a commericial one you bought? If a commercial one what is the brand and model? If you designed it give us the schematic.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 03, 2004 11:29 am     Reply with quote

Quote:
You cannot have 7 LEDs connected to Port A there are only 6 connections so I would double check and determine where/how they are really connected. PLease tell us what PINS they are connected to.


You can if you use an external clock on osc1 Wink
love_hina
Guest







here's the details...
PostPosted: Wed Aug 04, 2004 7:15 pm     Reply with quote

Sorry that i miss out all those info..
yes..i will answer those questions... here they are:

1.i'm using MPLAB v6.4

2.the push button is connected to pin 14 together with a resistor to 5V
which means from pin 14 split to push button and resisotr and 5V

3.i also noticed that there are only 6 pins so i was wondering if i just use
6 LEDs. and i connected them to port B

4.the LEDS are connected in this way:

Pin header---resistor_0805(330ohm)---LED---GND

total of 7 pin header...

5.i designed it..how am i able to give u the schematic?? i dunno if how i
can attach it...
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Next Step - decisions
PostPosted: Wed Aug 04, 2004 8:56 pm     Reply with quote

OK , with an 18F252 the switch is connected to pin 14 which is RC3 and is normally high going low. Your LEDs are wired for HIGH=ON and I would recommend using Port B for the LEDs but that can be a problem if you are usng in-circuit programming. Also, you will need C6/C7 to use the UART later so, assuming you ARE using in circuit programming and you have to have 7 LEDs then the best move may be to split the LEDs between A and B or B and C.

Are using an external clock circuit feeding the PIC or a XTAL? As was pointed out earlier with an external osc you CAN use A0-A6 BUT A4 is an open collector so your LED wiring would have to be changed to use Port A.

Questions:
1. Faced with the above how do you want to connect the LEDs?

2. What kind of programmer are you using?

3. What version of PCH compiler are you using?
chingB



Joined: 29 Dec 2003
Posts: 81

View user's profile Send private message

PostPosted: Wed Aug 04, 2004 10:15 pm     Reply with quote

Try this circuit schematics for your experiment....
off-course u shud make the program... and figure it out from the examples in this community.

I hope this helps.....

Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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