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.

Serial Lcd code Porting?

Status
Not open for further replies.

1Steveo

New Member
I need to use a 16f676 instead of a 16f630. The 676 has "AD" and the 630 dose not! So I need to turn of the AD converter (Ansel = 0 in basic) .
The code is in "asm". I'm Brain Dead when it comes to "ASM" programming!
Here is a link to the code that I wish to Port.
https://www.sparkfun.com/tutorial/TestHex/LCD/serlcd-v1.asm
Can I just remove the comments in the " boot_up " routine?
( ; //ANSEL = 0b.0000.0000; //Disable ADC on all pins - Only on the 16F676 )

Thanks for looking!
steve
 
Note: The ANSEL (9Fh) and CMCON (19h)
registers must be initialized to configure an
analog channel as a digital input. Pins
configured as analog inputs will read ‘0’.
The ANSEL register is defined for the
PIC16F676.
Code:
bcf STATUS,RP0 ;Bank 0
clrf PORTA ;Init PORTA
movlw 05h ;Set RA<2:0> to
movwf CMCON ;digital I/O
bsf STATUS,RP0 ;Bank 1
clrf ANSEL ;digital I/O
movlw 0Ch ;Set RA<3:2> as inputs
movwf TRISA ;and set RA<5:4,1:0>
;as outputs
bcf STATUS,RP0 ;Bank 0


Just put this code in the firs line of boot_up.
Check and adjust you in and out need's.
Read datasheet from page 1-132, or at least page 21.

Have fun.
 
Thanks casab911.
I have read the "data sheet" over and over!!!
IF I paste your code to the asm file , I see a duplicate " movwf CMCON " .
Should I remove part of the "boot_up" routine and paste your code there?
Also Do I need to include the "ANSEL" address to the top of the code?

Steve
 
nonono
if yuo look at the code posted at sparkfun...., you will see there is already a code to make the pins digital .
Code:
    ;    //Setup Ports
            ;    //ANSEL = 0b.0000.0000; //Disable ADC on all pins - Only on the 16F676
            ;    CMCON = 0b.0000.0111; //Turn off comparator on RA port 
    MOVLW .7
    MOVWF CMCON
It should work like that !
The 05 hex in Microchips example if equall of decimal 7 in spakfun's code.

csaba911
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top