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.

Student with the pic blues, all code, no action

Status
Not open for further replies.

rostifa

New Member
Hi, i'm a newcommer to the world microcontrollers and started on my first (hopefully of may) pic project for my final year in university, using the PIC16F877. The project involves creating a 'laser' targeting system for model aircraft. I have used infrared techniques used in lazer quest games for the system coupled with a nice pair of tranceiver modules and an LCD.

Anyway, after months researching and designing the code, all was good. I write the code in CCS and modeled my design (well the LCD anyway) in proteus VSM and it worked great. Finally last week i committed my design to silicone, before placing in my PCB only for nothing to happen!! :-(.

The LCD just produced 20 black squres and nothing else. On trying to debug i found that i had used 33uf instead of pf oscillator capacitors and changed them. Still nothing. So on the advice of one of the techs i wrote basic code just to turn on and off LEDs attached to portA. This seemed to work on the ICD demo board, but again not in my PCB?

After reading the notes for the forum i realise the LED on RA4 wouldnt work anyway because it is open drain type but i dont know why the rest dont. I have disabled the analogue inputs and made sure the tris is correct. There deffinately is 5V to the PIC. Do you think i could have damaged the 4Mz Xtal (XT setting) with the wrong caps? Maybe that would explain why nothing is happening. I am REALLY lost now. Even the uni tech couldnt help. So if one of you can, or has any advice, please, please help!!!....

Ross
 
You have to post your LED flashing code here for us to look at, using the [c o d e] forum format code so that the spacing in the ASM file are retained.
 
Finally somebody who reads the Sticky first!

Post us your code, schematic and a PCB image. That's the minimum we need to help you.

Jay.
 
Uh, ok i will try, but i think the problem lies in the hardware as the program works on portc in the MPLab ICD demo board, but when i change the code to porta, beging careful to ensure i turn the pins to digital IO and set the tris correctly is doesnt work in my PCB. As there is definatley power i figured it might be the oscillator. I supose i should try checking this on a scope but im not sure ehat levels i should be looking for. The frequency is 4mhz. I just wondered if anyone has any advice on hardware issues.

I did at one point forget a series res in with an LED on port A :oops: . I know port c still works but would this blow all of port A maybe?..

Will try an get the code up soon.

PS I have proteus VSM 5.2. This runs the simulations with the LCD ok but i cant view the source code as it was created through CCS C compiler in MPLAB. Is there any way to do this, or do i need to upgrade to a newer version?

Cheers Ross
 
rostifa said:
I did at one point forget a series res in with an LED on port A :oops: . I know port c still works but would this blow all of port A maybe?..

It's improbable. PICs are pretty sturdy devices so LEDs shouldn't hurt them (if you do not abuse them like this for extensive periods of time).
 
if you have not done so, make sure that:

You send the appropiate initialization commands to the LCD. This is required before the LCD can display any characters. If yours is a text-based LCD and it has 14 or 16 connection points, then it might contain an HD47780 chip. You can do a search on the internet for this kind of information and you will find out how to use it.

you must limit current! This is VERY important, and applies to every circuit built. If current was not limited, the load (whatever is consuming battery power, such as lights) is more than likely to be destroyed. You might want to replace the LCD in your case.

Does ANY part of your project work the way you expected it to?
 
Hmm

After replaceing my oscillator caps that were incorrectly stamped i found the circuit would work with a pic16f877a but not the normal 877s i had bought. Does anybody know what the difference is between the two and why things will not work on the normal 877. I used CCS C complier through MPLab to create the hex files and these were set to the correct chip version, so i cant see where the problem lies. Anybody know...

Please help, Ross
 
You need to start small. Write code that turns one pin on and off in the main code loop and turns another pin on and off with interrupts. Rather than strobing, you want to use RB1=!RB1 so it maintains a more observable ~50% duty cycle. You need an oscilloscope to view it.

mstechca said:
you must limit current! This is VERY important, and applies to every circuit built. If current was not limited, the load (whatever is consuming battery power, such as lights) is more than likely to be destroyed. You might want to replace the LCD in your case.

It could destroy an LED, but I have no idea what he's talking about in limiting current in ever circuit or destroying an LCD. There's no need to limit current to these since they're 5v devices.
 
thanks guys, i really appriciate the advice. Gotta take all you can get when you're starting i guess aye.

I solved the oscillator problem but changing the caps on the crystal. Then I even got the LCD running using a mates PIC16F877A chip but it still would not run when the same code was used on my PIC16F877 version of the chip. I dont see why this is as there are no real differences in the PIC pin wise. Does anybody know what the differences are between these two and why i am getting these strange problems?
 
These chips have different programming 'methods', are you changing the settings in whatever programmer software you are using (and/or the device directives in the program before reassembling)?

Rick
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top