Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 9th March 2004, 08:42 PM   (permalink)
Default Programming Languages

Hey everyone,
Can someone suggest a simple programming language i can learn so i can program a 16F877A that i bough, using MPLAB. Im using it for an enginnering project at college and ive only really used flowsheets before so a fairly simple one would be nice, cheers!!

Chris
christophe is offline  
Old 10th March 2004, 06:47 AM   (permalink)
Default Re: Programming Languages

Quote:
Originally Posted by christophe
Hey everyone,
Can someone suggest a simple programming language i can learn so i can program a 16F877A that i bough, using MPLAB. Im using it for an enginnering project at college and ive only really used flowsheets before so a fairly simple one would be nice, cheers!!

Chris
As you've got MPLAB, you've already got the MicroChip Assembler. As it's a RISC chip it's not too hard to learn, only 35 instructions in total, some of which you only rarely use. Have a look at my PIC tutorials at http://www.winpicprog.co.uk, which are based (mainly) on the 16F628, but move easily to the 877.

The only other free language is JAL (Just Another Language), but you should really be reasonably proficient in assembler before using anything else.

Personally I don't use MPLAB, I just use the assembler MPASM, which is installed along with it typing the code using Notepad and then assembling it with MPASM.
Nigel Goodwin is offline  
Old 10th March 2004, 09:10 AM   (permalink)
Default

Thanks for the advice Nigel, you're tutorials look really good, but for tutorial 1 which lines do i need to amend to make the program sutiable for a 16F877A, is it just the 5th and 6th and if so wot do i put it there,
thanks
christophe is offline  
Old 10th March 2004, 09:37 AM   (permalink)
Default

Quote:
Originally Posted by christophe
Thanks for the advice Nigel, you're tutorials look really good, but for tutorial 1 which lines do i need to amend to make the program sutiable for a 16F877A, is it just the 5th and 6th and if so wot do i put it there,
thanks
If you look at tutorial 11, this uses an 876/877, you can get the details from there - for one, the config value is different. But you usually need to turn off the A2D converters as well, this is a code snippit from tut 11.
Code:
		BANKSEL ADCON1			;disable A2D
    		movlw   0x06
    		movwf   ADCON1
    		BANKSEL PORTA
I'm not sure if you need to do anything else for the A version, I've not used one - you would need to check the datasheets, MicroChip usually provide a 'migration' sheet - for moving programmes from the 877 to the 877A - that should tell you if you need to do anything else.
Nigel Goodwin is offline  
Old 11th March 2004, 08:33 AM   (permalink)
Default

Does any one happen to know what the config value for a 16F877A - I/P is, as i cant seem to find it on the microchip website. Also what does the I/P at the end stand for??? Cheers
christophe is offline  
Old 11th March 2004, 03:25 PM   (permalink)
Default

The config value depends on your hardware, (using a crystal or a RC?, want MCLR enabled or not? , ...)

The P just means it's a PDIP part.
Exo is offline  
Old 11th March 2004, 03:57 PM   (permalink)
Default

Im using a 4Mhz ceramic resonator and i want memory clear to be enabled, basicly i just want a test program that will work with a 16F877A to check i have got the circuit and the programmer working right
christophe is offline  
Old 11th March 2004, 07:52 PM   (permalink)
Default

Quote:
Originally Posted by christophe
Im using a 4Mhz ceramic resonator and i want memory clear to be enabled, basicly i just want a test program that will work with a 16F877A to check i have got the circuit and the programmer working right
WinPicProg very handily gives you the value for __CONFIG when you select the options on screen - for a 16F877A with XT (4MHz) oscillator the value is 0x2909. But in any case, you can simply select your config options in the programmer software after loading the HEX file.
Nigel Goodwin is offline  
Old 11th March 2004, 08:19 PM   (permalink)
Default

I am now using one of you're programs Nigel which has been slightly altered but i still cant get my circuit to work right, Is the program wrong or is there a problemwith my circuit

;Tutorial 1.1 - Nigel Goodwin 2002
LIST p=16F877A ;tell assembler what chip we are using
include "P16F877A.inc" ;include the defaults for the chip
__config 0x2909 ;sets the configuration settings
;(oscillator type etc.)

org 0x0000 ;org sets the origin, 0x0000 for the 16F628,

BANKSEL ADCON1 ;this is where the program starts running
movlw 0x06
movwf ADCON1 ;turn comparators off (make it like a 16F84)
BANKSEL PORTA

bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf TRISB
movwf TRISA ;set PortA all outputs
bcf STATUS, RP0 ;select bank 0

Loop
movlw 0xff
movwf PORTA ;set all bits on
movwf PORTB
nop ;the nop's make up the time taken by the goto
nop ;giving a square wave output
movlw 0x00
movwf PORTA
movwf PORTB ;set all bits off
goto Loop ;go back and do it again

end
christophe is offline  
Old 11th March 2004, 08:26 PM   (permalink)
Default

What happens when you run it?.
Nigel Goodwin is offline  
Old 11th March 2004, 08:46 PM   (permalink)
Default

I put it in my circuit which has LED on all the port B outputs and nothing happens. My Other LED comes on to show ive got power (Its just connected across the power lines) and ive checked ive got voltages at the chip in the right places. The only thing i can think of that might be wrong is the oscillator its a 4MHz ceramic resonator
[/url]http://uk.farnell.com/jsp/search/searchresultstwo.jsp;jsessionid=IEKJGNQLBP1PRQFIAE XCFE4AVAAS2IV3?_dyncharset=ASCII&action=1&ImgDisp= Y&KWord=&NPart=295267&MPart=&MName=&QText=&_DARGS= %2Fjsp%2Fsearch%2Fcontent%2Fadvancedproductsearchc ontenttwo.jsp.1&x=0&y=0http://<br /> <br /> its connected... this right???
christophe is offline  
Old 12th March 2004, 05:49 AM   (permalink)
Default

i believe a ceramic resonator already has the proper capitors built-in. The middle pin of the resonator goes to earth and the pins on the sides go to the clock in/out of the 'F677.

you don't need the capaitors on the resonator.
__________________
www.winpicprog.co.uk - Great PIC language tutorials.
pike is offline  
Old 12th March 2004, 06:54 AM   (permalink)
Default

As Pike has already said, you shouldn't need external capacitors with a ceramic resonator - they come with three pins, and include them internally, the middle pin been the ground connection of the capacitors.

If your resonator only has two pins, it's probably not the correct type.
Nigel Goodwin is offline  
Old 12th March 2004, 08:45 AM   (permalink)
Default

which is the best resonator to use then?? or should i change to a crystal, Is there any in the farnell online catalogue that would do??? Also am I still alright with 4MHz
christophe is offline  
Old 12th March 2004, 09:52 AM   (permalink)
Default

Quote:
Originally Posted by christophe
which is the best resonator to use then?? or should i change to a crystal, Is there any in the farnell online catalogue that would do??? Also am I still alright with 4MHz
I mostly use crystals, although I have used the occasional ceramic resonator. 4MHz is fine, I usually use either 4MHz or 20MHz, but be aware that for 4MHz you set the oscillator to XT and for 20MHz to HS.

I might also mention that the first tutorial, which you quoted, flashes the LED's far too fast to see any flashing - the second one explains why, and modifies the first routine.

If you have access to a scope, try checking for oscillation on the PIC oscillator pins, you will need to use a x10 probe, a x1 probe will stop the oscillator anyway.
Nigel Goodwin is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:23 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker