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.

Program not working (16F74)

Status
Not open for further replies.

imhereithink

New Member
Right now iv programed the PIC the program now doesnt work lol.

What i am trying to accomplish is the 16F74 reads in an analogue voltage on AD0, this voltage comes from a sample/hold device which is controlled by the PIC. So the PIC enables the sample/hold device to let data though by setting RB0 high, once high the data then enters AD0. This is then converted, this result is then placed from ADRES onto TXREG to transmit through the USART, then repeat.
Once i have this working i will then extend it to three analogue inputs. I have attached the circuit diagram and the .asm file.

Any pointers in the right direction would be greatly appreciated.

p.s. this is my first time with the 16f74 :rolleyes:
 

Attachments

  • 16F74 module.jpg
    16F74 module.jpg
    104.3 KB · Views: 253
  • USART.asm
    7 KB · Views: 134
You use an include file that's good. Get rid of the SFR equates you don't need them. The PIC16F74 has an A/D mux why do you have external sample & holds?
You have an ICD2, use a 16F877A and you'll enjoy the debug mode (I don't think the 16F74 has debug I could be wrong though)
Do your sample & holds work? Did you add 0.1uf decoupling caps on the power pins of all digital ICs? Where's the crystal?
 
Last edited:
Sorry for the late reply here,

Before this PIC was chosen it was decided to use the sample/hold devices. As you quite rightly pointed out this PIC includes a A/D mux. So i have gone and changed the circuit so the analogue inputs go straight to the pins an0/an1/an2 and selecting these in the program before starting a conversion. By doing this it makes the board alot neater and less complicated.

As for the SFR equates thats the way iv been teached to write all my programs, so i have gotten rid of them ;)

I forgot to include the 20MHz crystal in the circuit diagram, but it is there honest :p

Iv attached the new .asm file for you to see the changes, it builds without errors, just need to check it on the PIC now :D

Thanks for the pointers
 

Attachments

  • USART2.asm
    5 KB · Views: 123
On a quick glance two things instantly spring to mind!.

1) Have you ever heard of subroutines?.

2) Your program doesn't have any 'ending' it just crashes straight past the end of your program and will run right through all memory before restarting at the reset vector. This isn't a very good idea!, you should include a loop back to somewhere (even if it's just an endless loop).

You might try consulting my tutorials, which really do everything you want!.
 
LOL i just noticed that i missed out the goto sensor1 at the end there :rolleyes: thats the first time iv ever forgotten to do that :p
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top