ASM - Problem at first step!


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: ASM - Problem at first step!

    There are .asm template files in your MPASM directory that show basic templates for beginners.

    Look in C:\Program Files\Microchip\MPASM Suite\Template\Code

    For a template for the 16F676.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: ASM - Problem at first step!

    Thanks Bruce
    Really useful information.

  3. #3
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: ASM - Problem at first step!

    I am able to compile it now but it is not working. I am using Proteus 7.9 software to simulate it but
    Is something wrong with the code?
    Code:
    	LIST P=16F676
    	#include <p16F676.inc>
    	__CONFIG   _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
    
    	ORG	0
    	GOTO	5
    	ORG	4
    	GOTO	5
    	ORG	5
    
    	CLRF	H'07'
    	BSF	H'03',5
    	CLRF	H'07'
    	CLRF	H'91'
    	BCF	H'03',5
    
    	BSF	H'07',4
    	BSF	H'07',5
    	BSF	H'07',2
    	BSF	H'07',3
    
    	END

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: ASM - Problem at first step!

    couple of mistakes in there... no problem it's your first I guess

    You haven't cleared the TRISC register
    no real need for multiple ORG and GOTO at the begining
    If you want to use GOTOs, you want to use/define some label and jump to them.
    It's really more readable to use register name instead of their addresses.
    Make suire you're always in the good BANK when writing/writing to a registers. Datasheet show everything 'bout that
    Maybe not a bad idea to retrieve the oscillator calibration at the begining.

    Like Bruce said, check out your MPASM\Template\CODE folder.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: ASM - Problem at first step!

    Quote Originally Posted by mister_e View Post
    couple of mistakes in there... no problem it's your first I guess

    You haven't cleared the TRISC register
    no real need for multiple ORG and GOTO at the begining
    If you want to use GOTOs, you want to use/define some label and jump to them.
    It's really more readable to use register name instead of their addresses.
    Make suire you're always in the good BANK when writing/writing to a registers. Datasheet show everything 'bout that
    Maybe not a bad idea to retrieve the oscillator calibration at the begining.

    Like Bruce said, check out your MPASM\Template\CODE folder.
    Thanks. I was under the impression that the below statements clear the TRISC register.

    Code:
    	CLRF	H'07' ; clear portC
    	BSF	H'03',5  ; Jump to bank 1
    	CLRF	H'07'  ; Clear Trisc
    	CLRF	H'91' ; Clear ANSEL register
    	BCF	H'03',5  ; Jump to Bank 0

  6. #6
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: ASM - Problem at first step!

    Even tried this now. But
    Code:
    	......
    	ORG	5
    
    	CLRF	PORTC
    	BSF	STATUS,RP0
    	CLRF	TRISC
    	CLRF	ANSEL
    	BCF	STATUS,RP0
    	BSF	PORTC,4
    	BSF	PORTC,5
    	BSF	PORTC,2
    	BSF	PORTC,3
    
    	END

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: ASM - Problem at first step!

    Compiles and works fine in MPLAB SIM. PORTC bits 4,5,2,3 all get set. Post your Protous file and we can have a look for you.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts