Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:34 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Programming in assembly language

Author Message
Worm

Newbie

Joined: 30/06/2011
Location: New Zealand
Posts: 38
Posted: 01:12am 15 Oct 2011
Copy link to clipboard 
Print this post

Does anybody know of a good forum on progamming in assembly language? Trying to search for code snippets on the 12f617 is proving difficult. Any advice would be appeciated.

Kevin
There's no such thing as a free lunch.
 
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 02:00am 15 Oct 2011
Copy link to clipboard 
Print this post

What do you need ??
ken
 
Worm

Newbie

Joined: 30/06/2011
Location: New Zealand
Posts: 38
Posted: 02:25am 15 Oct 2011
Copy link to clipboard 
Print this post

Hi Ken

Ive written a program using a 10f206 and now want to transfer the program to a 12f617. The problem for me is I find it very difficult to understand the data sheets. I need to configure the 12f617 for 2 inputs and 3 outputs, and also how to turn on a O/P. If I had some code to blink a LED, I then could work out how to modify it untill I can get it to work with my own program.

Kevin
There's no such thing as a free lunch.
 
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 04:45am 15 Oct 2011
Copy link to clipboard 
Print this post

http://www.voti.nl/swp/ is a good start
any reason for the 12f671 ? 12f683 is a better part plus 256 bytes eeprom and probably cheaper .
and if you need more speed 12f1822 is a great part.
they are all the same 35 instructions to learn.
The company i work for probably buys a few million of 683 and 1822's a year so i do a lot of stuff with them

ken
 
Worm

Newbie

Joined: 30/06/2011
Location: New Zealand
Posts: 38
Posted: 05:18am 15 Oct 2011
Copy link to clipboard 
Print this post

Hi Ken

The reason for using a 12f617 is I have 10 of them. Ive had a quick look at that web site you sugested. They have code to flash a LED but it is not in asm or for 12f617,s. The problem I am having is learning how to configure the more complex micros. Thats why I asked for code specific for a 12f617.

Kevin
There's no such thing as a free lunch.
 
Olimex
Senior Member

Joined: 02/10/2011
Location: Bulgaria
Posts: 226
Posted: 06:29am 15 Oct 2011
Copy link to clipboard 
Print this post

www.piclist.com have nice archive
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1344
Posted: 07:59am 15 Oct 2011
Copy link to clipboard 
Print this post

Hi Kevin,
For getting your feet wet in assembly language you can't go past Nigel Goodwin's pic Tutorials.

Regards Bryan
 
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 11:44pm 17 Oct 2011
Copy link to clipboard 
Print this post

You can use JALv2 language to blink a LED then, you can study the .asm file. You have support for that on Jallib libraries. It's all free.

[code]include 12f617 -- target PICmicro
--
-- This program assumes that a 20 MHz resonator or crystal
-- is connected to pins OSC1 and OSC2.
-- (unspecified configuration bits may cause a different frequency!)
pragma target clock 20_000_000 -- oscillator frequency
-- configuration memory settings (fuses)
pragma target OSC HS -- HS crystal or resonator
pragma target WDT disabled -- no watchdog
pragma target MCLR external -- reset externally
-- These configuration bit settings are only a selection, sufficient for
-- this program, but other programs may need more or different settings.
--
enable_digital_io() -- make all pins digital I/O
--
-- Specify the pin to which the LED (with serial resistor!) is connected:
alias led is pin_A0
pin_A0_direction = output
--
forever loop
led = on
_usec_delay(250_000)
led = off
_usec_delay(250_000)
end loop
--
[/code]

And the resulted assembler:
[code]; compiler: jal 2.4o (compiled May 8 2011)

; command line: ../compiler/jalv2 -s ../lib 12f617_blink.jal
list p=12f617, r=dec
errorlevel -306 ; no page boundary warnings
errorlevel -302 ; no bank 0 warnings
errorlevel -202 ; no 'argument out of range' warnings

__config 0x3ff2
datahi_set macro val
bsf 3, 6 ; STATUS<rp1>
endm
datahi_clr macro val
bcf 3, 6 ; STATUS<rp1>
endm
datalo_set macro val
bsf 3, 5 ; STATUS<rp0>
endm
datalo_clr macro val
bcf 3, 5 ; STATUS<rp0>
endm
irp_clr macro
bcf 3, 7 ; STATUS<irp>
endm
irp_set macro
bsf 3, 7 ; STATUS<irp>
endm
branchhi_set macro lbl
nop
endm
branchhi_clr macro lbl
nop
endm
branchlo_set macro lbl
bsf 10, 3 ; PCLATH<3>
endm
branchlo_clr macro lbl
bcf 10, 3 ; PCLATH<3>
endm
v_on EQU 1
v_off EQU 0
v_output EQU 0
v__gpio EQU 0x0005 ; _gpio
v__porta_shadow EQU 0x0023 ; _porta_shadow
v_cmcon0 EQU 0x001a ; cmcon0
v_cmcon1 EQU 0x001c ; cmcon1
v_adcon0 EQU 0x001f ; adcon0
v_trisio EQU 0x0085 ; trisio
v_pin_a0_direction EQU 0x0085 ; pin_a0_direction-->trisio:0
v_ansel EQU 0x009f ; ansel
v__pic_temp EQU 0x0020 ; _pic_temp-->_pic_state
v__pic_state EQU 0x0020 ; _pic_state
v___x_22 EQU 0x0023 ; x-->_porta_shadow:0
v___x_23 EQU 0x0023 ; x-->_porta_shadow:0
; 25 include 12f617 -- target PICmicro
org 0
l__main
; 38 enable_digital_io() -- make all pins digital I/O
; ../lib/12f617.jal
; 462 ANSEL = 0b0000_0000 -- all digital
datalo_set v_ansel
clrf v_ansel
; 12f617_blink.jal
; 38 enable_digital_io() -- make all pins digital I/O
; ../lib/12f617.jal
; 484 analog_off()
; 12f617_blink.jal
; 38 enable_digital_io() -- make all pins digital I/O
; ../lib/12f617.jal
; 469 ADCON0 = 0b0000_0000 -- disable ADC
datalo_clr v_adcon0
clrf v_adcon0
; 12f617_blink.jal
; 38 enable_digital_io() -- make all pins digital I/O
; ../lib/12f617.jal
; 485 adc_off()
; 12f617_blink.jal
; 38 enable_digital_io() -- make all pins digital I/O
; ../lib/12f617.jal
; 476 CMCON0 = 0b0000_0000 -- disable comparator
clrf v_cmcon0
; 477 CMCON1 = 0b0000_0000
clrf v_cmcon1
; 12f617_blink.jal
; 38 enable_digital_io() -- make all pins digital I/O
; ../lib/12f617.jal
; 486 comparator_off()
; 12f617_blink.jal
; 38 enable_digital_io() -- make all pins digital I/O
; 42 pin_A0_direction = output
datalo_set v_trisio ; pin_a0_direction
bcf v_trisio, 0 ; pin_a0_direction
; 44 forever loop
l__l46
; 45 led = on
datalo_clr v__porta_shadow ; x22
bsf v__porta_shadow, 0 ; x22
; ../lib/12f617.jal
; 202 _PORTA = _PORTA_shadow
movf v__porta_shadow,w
movwf v__gpio
; 12f617_blink.jal
; 45 led = on
; 46 _usec_delay(250_000)
datalo_clr v__pic_temp
datahi_clr v__pic_temp
movlw 167
movwf v__pic_temp
l__l56
movlw 9
movwf v__pic_temp+1
l__l57
movlw 165
movwf v__pic_temp+2
l__l58
branchhi_clr l__l58
branchlo_clr l__l58
decfsz v__pic_temp+2,f
goto l__l58
branchhi_clr l__l57
branchlo_clr l__l57
decfsz v__pic_temp+1,f
goto l__l57
branchhi_clr l__l56
branchlo_clr l__l56
decfsz v__pic_temp,f
goto l__l56
nop
nop
; 47 led = off
bcf v__porta_shadow, 0 ; x23
; ../lib/12f617.jal
; 202 _PORTA = _PORTA_shadow
movf v__porta_shadow,w
movwf v__gpio
; 12f617_blink.jal
; 47 led = off
; 48 _usec_delay(250_000)
datalo_clr v__pic_temp
datahi_clr v__pic_temp
movlw 167
movwf v__pic_temp
l__l59
movlw 9
movwf v__pic_temp+1
l__l60
movlw 165
movwf v__pic_temp+2
l__l61
branchhi_clr l__l61
branchlo_clr l__l61
decfsz v__pic_temp+2,f
goto l__l61
branchhi_clr l__l60
branchlo_clr l__l60
decfsz v__pic_temp+1,f
goto l__l60
branchhi_clr l__l59
branchlo_clr l__l59
decfsz v__pic_temp,f
goto l__l59
nop
nop
; 49 end loop
goto l__l46
end
[/code]

I don't know if it helps for your assembler but... you can get nice results in JALv2...

The project page is here,

Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024