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 said:
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
Wow, never seen this before, but I bet it has to do with PICSTART plus...
 
striker2509 said:
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

Check the datasheet; the COMF instruction complements all bits of a register. That is, it turns 1s to 0s and 0s to 1s.

So each time the interrupt occurs you would see all the bits of PORTC changing state. An LED on any of the PORTC pins would work.

Here's a useful interrupt routine that saves/restores W and STATUS:
Code:
org 0004

; save W and STATUS
movwf W_TEMP
movf STATUS, w
clrf STATUS
movwf STATUS_TEMP

; put your interrupt handling code here

; restore W and STATUS
movf STATUS_TEMP, w
movwf STATUS
swapf W_TEMP, f
swapf W_TEMP, w

retfie
 
Hi mike....look....i think i didn't explain it very well...let me try again

1. the interrupt routine its suppose to be working, right, as you just told me....its supossed to change on and off... the question is... RB4-RB7 are low....when i switch one of them.....no matter which one...the led flashes like 5 seconds and then remains on....as i understand the code...its suppose to turn on (if the led is off) when an interrupt occurs....right?

2. The other thing is....Should i erase portB value or so...because as i can see the program takes the initial value of RB4-RB7 and saves it. And no matter if i reset the pic....it takes the saved value...As i said before, the pic is acting that way

3. Going a bit farther, if i want to set some output pins after an interrupt occurs, should i do this in the ISR or in the main loop, cause as u told me, the ISR only takes 5 seconds to act...right?

Thanks again
Striker
 
By the way, maybe i should put the code here.....in order that other people can see it

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


W_TEMP EQU 0x21
STATUS_TEMP EQU 0x22

ORG 0000
GOTO configuration
ORG 0004
MOVWF W_TEMP
MOVF STATUS, W
CLRF STATUS
MOVWF STATUS_TEMP
COMF PORTC,F
BCF INTCON, RBIF
MOVF STATUS_TEMP,W
MOVWF STATUS
SWAPF W_TEMP,F
SWAPF W_TEMP,W
RETFIE


configuration BSF STATUS, 5 ;return to bank 1
MOVLW B'11110000'
MOVWF TRISB ;RB4 - RB7 as inputs
CLRF TRISC ;RC0 - RC7 as outputs
BCF STATUS, 5 ;return to bank 0
BSF INTCON, RBIE
BSF INTCON, GIE

mainloop
GOTO mainloop ;Go back and do it again

END
 
striker2509 said:
1. the interrupt routine its suppose to be working, right, as you just told me....its supossed to change on and off... the question is... RB4-RB7 are low....when i switch one of them.....no matter which one...the led flashes like 5 seconds and then remains on....as i understand the code...its suppose to turn on (if the led is off) when an interrupt occurs....right?
I don't know where the 5 seconds comes from. The code I posted before didn't have any delays in it. It just changed the state of PORTC every time an interrupt on PORTB occured. At least it should; I didn't try it out.

If you want it to flash for 5 seconds every time, then you'll need to write the flash-for-5-seconds part and use it instead of the COMF line.

striker2509 said:
2. The other thing is....Should i erase portB value or so...because as i can see the program takes the initial value of RB4-RB7 and saves it. And no matter if i reset the pic....it takes the saved value...As i said before, the pic is acting that way
The code I had posted doesn't save the value on PORTB. And you can't clear the value of inputs.

striker2509 said:
3. Going a bit farther, if i want to set some output pins after an interrupt occurs, should i do this in the ISR or in the main loop, cause as u told me, the ISR only takes 5 seconds to act...right?
The ISR takes as long as your code. You could write an ISR to take 1uS or you could write one to take 100 years.

Your ISR *should* only take as little time as necessary.

I think we're all confused about what you're trying to do.

Mike
 
As i was saying to Jay.Slovak, its very hard to explain something in a foreign language. But im tried to be explicit. Sorry if i confused you.

The flashing of the led during the interruption could occur just because im switching the RB4-RB7 manually?

My project consist in develop a Switching Matrix for some Measurement Equipment. Sorry for my english so far and foward.

Now, The Switching Matrix (work with biestables latches) is 20x20, one latch per connection point. Follow me. Now, in order to controlled the 400 switches (latches), i thougth that i can save a lot of space using demux (4 to 16 lines) and i could connect one latch per demux output.

Implement the circuit this way, im only need control signals (from the pic) in the demux enable pin. And 4 data bits that tells the demux which latch must be set. Right?

In the final project. The RB4-RB7 are data bits from the PC. There is 14 circuits in the evaluation (measurement test) proccess. And 4 bits data gives me the possiblity of 16 diferent circuits. Now, every circuit does not connect more than 20 points (max, i think). And checking the value of Pins RB4-RB7, the pic has to set the latches associated with that value.

I hope you understand me know mike. Right now, im just working with 1 demux, in the final project, some pics (like 3) has to control like 20 demux and give them the data bits to activate the latches.

If anyone here knows spanish. Well, i gladly explain it in spanish.

Hoping you are not confused anymore. Thanks again pal

Striker
 
striker2509 said:
As i was saying to Jay.Slovak, its very hard to explain something in a foreign language. But im tried to be explicit. Sorry if i confused you.

The flashing of the led during the interruption could occur just because im switching the RB4-RB7 manually?

My project consist in develop a Switching Matrix for some Measurement Equipment. Sorry for my english so far and foward.

Now, The Switching Matrix (work with biestables latches) is 20x20, one latch per connection point. Follow me. Now, in order to controlled the 400 switches (latches), i thougth that i can save a lot of space using demux (4 to 16 lines) and i could connect one latch per demux output.

Implement the circuit this way, im only need control signals (from the pic) in the demux enable pin. And 4 data bits that tells the demux which latch must be set. Right?

In the final project. The RB4-RB7 are data bits from the PC. There is 14 circuits in the evaluation (measurement test) proccess. And 4 bits data gives me the possiblity of 16 diferent circuits. Now, every circuit does not connect more than 20 points (max, i think). And checking the value of Pins RB4-RB7, the pic has to set the latches associated with that value.

I hope you understand me know mike. Right now, im just working with 1 demux, in the final project, some pics (like 3) has to control like 20 demux and give them the data bits to activate the latches.

If anyone here knows spanish. Well, i gladly explain it in spanish.

Hoping you are not confused anymore. Thanks again pal

Striker
OK, That explains a LOT. I guess Spanish and Portugese are different languages, so that won't help you...
 
striker2509 said:
dont get it, really dont

striker
I just ment I know somebody (RoboticInfo), who is Portugese, and Spain is right next to it... (but you might be in Brazil, so forgive me) :oops:
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top