Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help on how to program chip...

Status
Not open for further replies.

teknyc78

New Member
I want to program the chip to control some inputs and outputs with the pic18f452, i will be using the usart for serial commnication but how do I acitvate or use the ports to control electronic devices.

I know you need to enable the usart and the RC6/RC7 pins but I have know idea how to use the usart to control the selected ports for I/O.

Thankyou for looking and any help or asm program would greatly be appreciated and credited.....thanks again.
 
You first need to decide on how YOU want to send the control signals, once you have decided on a protocol you can then implement it in code.

Your PIC program needs to receive the data from the PC, either one byte or multiple bytes (depending on your protocol), then check what the data tells it to do, and perform that function.

For a very simple example, you could use single ASCII characters to set specific pins high or low - so, say 'A' means set pin a0 high, and 'a' means set it low - your program needs to take the received character from the USART and compare it to a series of valid characters, branching accordingly. If it receives a non-valid character, you could either discard it, or have some kind of error indication.
 
i would say binary codes, is this valid in controlling the ports.......the usart is in portC and the port I want to use is portB......have any suggestions?
thanks for replying quick......this is the best site....that I came across so far.....
 
teknyc78 said:
i would say binary codes, is this valid in controlling the ports.......the usart is in portC and the port I want to use is portB......have any suggestions?

Anything is valid, it's just a question of writing it!. But I don't really understand what you mean by 'binary codes'?.

It doesn't make any difference what port you use, you simply write the code accordingly.

I would suggest though, that you've picked a bad PIC for your level of experience, the 18F is a 'top range' device, as such it's more powerful and consequently more complicated than the 16F 'mid range' series.

If you have a look at my RS232 PIC tutorials it might help you somewhat?.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top