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.

Pic16f877 + "C/C++" + PICSTART plus

Status
Not open for further replies.

striker2509

New Member
Hi everyone. Im really desperate. Im one step closer to the edge. I have two weeks programming in Assembler and im going nowhere.

There is by any chance a way to program the pic in "C" code. Im really sick of assembler. Also im using PICSTART plus programmer. Dont know if u cant help me.

P.D. I really hate MPLAB, and its false debbugger
 
striker2509 said:
Hi everyone. Im really desperate. Im one step closer to the edge. I have two weeks programming in Assembler and im going nowhere.

There is by any chance a way to program the pic in "C" code. Im really sick of assembler. Also im using PICSTART plus programmer. Dont know if u cant help me.

P.D. I really hate MPLAB, and its false debbugger
Hmm, you sound pretty upset, what exactly is your problem?

Also please read https://www.electro-tech-online.com/threads/circuit-impedance-loading.15292/
 
Nigel has good tutorials for assembly if that's the language you want to use.

There is a free C compiler called CC5X, but it has code size limitations.

Other non-free C compilers for PICs:
CC5X (the full version)
CCS
PICC
C2C

And you can get a free student version of Microchip's C compiler for PIC18's.

Mike
 
what's exactly my problem.....let's see

1. when i compile the program in my laptop. It says there is no problem. When i build it on my desktop. It says something about a processor missmatch. I'd change the program several times and keeps saying the same thing.

2. when i debbug the program in MP sim, or something like that, the programs is perfect. Everything it's like its supposed to be. But when i put the pic in my circuit. It's death

3. Which are the open collectors outputs?

4. And it looks like i dont have a clue about interrupts. Im completlely lost in this
 
striker2509 said:
what's exactly my problem.....let's see

1. when i compile the program in my laptop. It says there is no problem. When i build it on my desktop. It says something about a processor missmatch. I'd change the program several times and keeps saying the same thing.

2. when i debbug the program in MP sim, or something like that, the programs is perfect. Everything it's like its supposed to be. But when i put the pic in my circuit. It's death

3. Which are the open collectors outputs?

4. And it looks like i dont have a clue about interrupts. Im completlely lost in this
1. In your Desktop PC, start MPLAB, Configure/Select Device and select the PIC you are working with.

2. Try HW connections! Post us your Code, Scheme and picture of it...

3. There is only one for 16Fs PortA,4

4. Read Nigel's tuttorials!
 
Talking about soon...i have to make this work before thrusday...that's soon.

About the hardware. its not big deal....just some leds connected to every pin im setting or clearing. Nothing else
 
by the way....im reading nigel's tutorial, and i cant find anything about interrupts. it has help me in timer and so. but i couldnt find any interrupts parts
 
striker2509 said:
Talking about soon...i have to make this work before thrusday...that's soon.

About the hardware. its not big deal....just some leds connected to every pin im setting or clearing. Nothing else
Well I don't think switching to C will save you, especially when you are running out of time :lol:
 
striker2509 said:
by the way....im reading nigel's tutorial, and i cant find anything about interrupts. it has help me in timer and so. but i couldnt find any interrupts parts
I can't help you with Nigel's tutorials, I found this site after I knew all the stuff that's in there, so I didn't read them very carefully... :shock:
 
striker2509 ,
software or hardware interrupt ?
i've only done one circuit with a hardware interrupt. but maybe i can help..
3. Which are the open collectors outputs?
let me check..
 
It something desperate im trying to do, im good programming in C, as i said, i hate assembly.

Another problem just ocurrs, i bought a PIC16F877 just this morning and the first time i programm it. In the screen appears something about errors in directions. Some kind of list with ADDRESS GOOD BAD...Have you ever see anything like that?
 
striker2509 said:
It something desperate im trying to do, im good programming in C, as i said, i hate assembly.

Another problem just ocurrs, i bought a PIC16F877 just this morning and the first time i programm it. In the screen appears something about errors in directions. Some kind of list with ADDRESS GOOD BAD...Have you ever see anything like that?
Can post us a screenshot?

Maybe it has to do with correct possitioning of code in program memory of the PIC (ie exclude interrupt part of memory from normal part)
 
this is my program...tell me what u think about it


what does it does...let me explain you.

Im just trying to see if i can set the pins rb4 - rb7 as input. When anyone of these input changes. AN INTERRUPTS ocurrs (at least thats what i want), it goes trought the ISR and turn PORTC, 0 on. While the rb4 - rb7 remains still, the PORTC, 1 will be switching on and off. Got it. It has to do that over and over again.

Let me take a screenshot of the error
 

Attachments

  • interrupt.txt
    1.6 KB · Views: 213
there it goes.....this ocurrs during the verify proccess

im using MPLAB v.7.01, it also occurs in V.7.10

and PICSTART plus as a programmer
 

Attachments

  • verify.jpg
    verify.jpg
    96.5 KB · Views: 1,107
striker2509 said:
this is my program...tell me what u think about it

For a start your interrupt routine doesn't save and restore anything, as a minimum you should save and restore W and Status. Also what is this line supposed to be? "MOVFW PORTB" - there's no such instruction!.
 
Nigel Goodwin said:
Also what is this line supposed to be? "MOVFW PORTB" - there's no such instruction!.
I think this is called "pseudo Instruction", some people use it instead of MOVF [reg],w...
 
I remember seeing this code before. Where was it...Microchip's forums? I know a few others and I pointed out several problems with it.

Ahh, found it: https://www.electro-tech-online.com...cuit-design-of-remote-control-doorbell.16268/

Striker, you need to simplify your program. If you're just testing interrupts then get rid of all that delay stuff and make it really simple: COMP the PORTC bits in the interrupt routine and don't do anything that uses W. Then you can add parts to see where it stops working properly.

Question...When does this code ever execute?
Code:
			CALL 	DIRECCION1
			CLRF 	PORTB
			CLRF	PORTC
Answer: never, because you have it after the end of your interrupt routine and before the beginning of your main code.

Try this:
Code:
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;	Author: Rafael Franceschi								:
;	Date: 01/06/05											:
;	Version: 1.7											:
;	Title: Prueba Matriz de Conmutacion						:
;	Description: Toma la senal de entrada del puerto B		:
;				RB4-RB7 y detecta cambios, enciende, 		:
;				un LED's del puerto C en la interrupcion	:
;				senales TTL (High and Low tanto en la		:
;				entrada como en la salida)					:
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
			
			LIST   P=Pic16F877

			errorlevel -302
			
			#include P16F877.inc
			
			__CONFIG _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_ON & _CPD_OFF & _LVP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC
		

COUNT1	EQU	21h

			ORG 	0x00
			GOTO 	CONFI
			ORG		0x04
			COMF	PORTC,f
			BCF		INTCON, RBIF
			retfie
	
CONFI	BSF 	STATUS, 5			;cambio al banco 1
			MOVLW	B'11110000'
			MOVWF	TRISB				;RB4 - RB7 son entradas
			CLRF	TRISC				;RC0 - RC7 como salidas
			BCF		STATUS, 5			;retorno al banco cero
			BSF 	INTCON, RBIE
			BSF		INTCON, GIE	
		
MAINLOOP
			goto	MAINLOOP			;go back and do it again

	END

Mike
 
ok, i already saved the W file in a W_temp register i created in direction 22h. i also eliminated the confusing NON EXISTING line

The ISR goes this way

COUNT1 EQU 21h
W_TEMP EQU 22h
STATUS_TEMP EQU 23h

INTER MOVWF W_TEMP
BSF PORTC,0
BCF INTCON, RBIF
retfie

and then? When i restore the W value....in the main? in the confi?. How can i save and restore the value of STATUS?
 
got it...thans mike....but in order to understand your code....i need to know...what does the comf instruction?

let me try your code. But how im supossed to watch if the interrupt is ocurring
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top