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.

Frequency Counter Source Code Modification

Status
Not open for further replies.

km

New Member
If you use the 16F84A for this project the software needs to be updated for bank switching to access the OPTION, TRISA and TRISB registers. The OPTION and TRIS commands compile with a warning in MPIDE but do not execute when burned in the 16F84A microcontroller.

This is quote at the "Weeder Frequency Counter PIC 16F84 port by Peter Cousens" website.



Can anyone tell me how to modify the code for the PIC 16F84A version? OR there have any related website?
 
km said:
If you use the 16F84A for this project the software needs to be updated for bank switching to access the OPTION, TRISA and TRISB registers. The OPTION and TRIS commands compile with a warning in MPIDE but do not execute when burned in the 16F84A microcontroller.

This is quote at the "Weeder Frequency Counter PIC 16F84 port by Peter Cousens" website.



Can anyone tell me how to modify the code for the PIC 16F84A version? OR there have any related website?

I wasn't aware that the 16F84A had problems with the OPTION and TRIS commands, although MicroChip have been advising against their use for years - but I can't say I've ever actually 'used' one.

All you need to do is load W with the value you want, and then write it to the register, like this:

Code:
BANKSEL OPTION_REG
movlw 0x12 ;whatever value you need!
movwf OPTION_REG

And the same for TRIS:
Code:
BANKSEL TRISA
movlw 0xF0
movwf TRISA

Don't forget to switch back to bank 0 after setting TRIS and OPTION_REG, as they are both in the same bank you can do them together with only one BANKSEL line.
 
Nigel Goodwin said:
Don't forget to switch back to bank 0 after setting TRIS and OPTION_REG, as they are both in the same bank you can do them together with only one BANKSEL line.

Thanks for your reply Nigel! :wink: To switch back to bank 0, you mean that the code is just

BANKSEL ;just this line correct?
 
km said:
Nigel Goodwin said:
Don't forget to switch back to bank 0 after setting TRIS and OPTION_REG, as they are both in the same bank you can do them together with only one BANKSEL line.

Thanks for your reply Nigel! :wink: To switch back to bank 0, you mean that the code is just

BANKSEL ;just this line correct?

BANKSEL PORTA would do it, or you could just use lines like these, rather than the compiler directive.

Code:
bsf 	STATUS,		RP0	;select bank 1

bcf	STATUS,		RP0	;select bank 0
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top