gnupic: Re: [gnupic] Cannot get 18f252 to blink


Previous by date: 24 Oct 2006 22:13:07 +0100 Re: [gnupic] Cannot get 18f252 to blink, Edward Tiong
Next by date: 24 Oct 2006 22:13:07 +0100 Re: [gnupic] Cannot get 18f252 to blink, Samuel Tardieu
Previous in thread: 24 Oct 2006 22:13:07 +0100 Re: [gnupic] Cannot get 18f252 to blink, Edward Tiong
Next in thread: 24 Oct 2006 22:13:07 +0100 Re: [gnupic] Cannot get 18f252 to blink, Samuel Tardieu

Subject: Re: [gnupic] Cannot get 18f252 to blink
From: David Froseth ####@####.####
Date: 24 Oct 2006 22:13:07 +0100
Message-Id: <453E81D1.3020503@umich.edu>

Edward,
	I don't think that 'banksel' is an assembly mnemonic.  Could that be a 
Basic or C command?
	Also, I think that with the 18f parts, all of the Special Function 
Registers (0x0f80-0x0fff) and the first 128 bytes of data memory 
(0x0000-0x007f) are easily accessed through the 'Access Bank'.  No bank 
switching is necessary.  I definitely could be missing something on 
this, though, since I cannot get this simple program running.

Thanks

Edward Tiong wrote:
> I think that you are not in proper banks when addressing the TRISA etc
> 
> you may want to add in the following lines
> 
> 
> 
>>;Inits
> 
> 	banksel ADCON1
> 
>>		movlw	b'00000110'
>>		movwf	ADCON1		;sets POARTA pins as digital I/O
> 
> 	banksel TRISA
> 
>>		movlw	b'11111110'		;Set the RA0 pin
>>		movwf	TRISA			;	to output.
>>		movlw	b'11111111'
>>		movwf	TRISB
>>		movlw	b'00000000'
>>		movwf	TRISC
>>
> 
> Also further in your code ...
> 
> 
>>flash_led
> 
> 	banksel PORTA
> 
>>		movlw		b'00000001'
>>		xorwf		PORTA,f
> 
> 
> 
> Ed
> 
> 
> 
> 
> On Tuesday 24 October 2006 12:17, David Froseth wrote:
> 
>>	I am having problems getting a 18f252 to flash an LED.  I am using a
>>PICSTART Plus with a Keyspan usb-serial adapter.  I am using gpasm and
>>picp with OS X.  This setup has worked for the 16f84a and the 16f870 chips.
>>	I have written this simple .asm program which compiles to a .hex file
>>successfuly:
>>
>>;Title:  0.1flash252
>>;File Saved As:  0.1flash252.asm
>>;Clock Frequency:  4 MHz
>>;PIC chip:  18F252
>>;
>>;Description:
>>;
>>;testing RA0 flash with 18f252;
>>;
>>;
>>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>;Processor type::
>>
>>		processor	18f252
>>
>>;List file directives
>>
>>		list		p=18f252
>>
>>;SFR equates and other 18fxxx specific declarations
>>
>>		include		"/sw/share/gputils/header/p18f252.inc"
>>
>>;Configuration bytes
>>
>>		__config	_CONFIG1H, b'00100001'	;XT oscillator
>>		__config	_CONFIG2L, b'00001110'	;enable power-up timer
>>		__config	_CONFIG2H, b'00001110'	;watchdog timer disabled
>>		__config	_CONFIG3H, b'00000001'	;CCP2 on RC1
>>		__config	_CONFIG4L, b'10000001'	;Disable LVP
>>
>>		;All other configuation bits involve code protection.
>>		;Default to protection-off (logic 1)
>>
>>
>>
>>		radix		dec
>>
>>;;;;;;;;;;;;;;;;;;;;;;;;;;
>>outer_delay		equ	0x20	;First counter
>>inner_delay		equ	0x21	;Second counter
>>
>>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>
>>		org		0x0000
>>		goto		MainLine
>>
>>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>;High-priority interrupt service routine:
>>		org		0x0008
>>
>>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>;Low-priority interrupt service routine:
>>		org		0x0018
>>
>>
>>
>>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>;Main body of the program
>>MainLine
>>
>>;;;;;;;;;;;;;;;;;;;;;;;;
>>;Inits
>>		movlw	b'00000110'
>>		movwf	ADCON1		;sets POARTA pins as digital I/O
>>		movlw	b'11111110'		;Set the RA0 pin
>>		movwf	TRISA			;	to output.
>>		movlw	b'11111111'
>>		movwf	TRISB
>>		movlw	b'00000000'
>>		movwf	TRISC
>>
>>;;;;;;;;;;;;;;;;;;;;;;;;
>>;Start
>>
>>flash_led
>>		movlw		b'00000001'
>>		xorwf		PORTA,f
>>		call		debounce
>>		goto		flash_led
>>
>>;;;;;;;;;;;;;;;;;;;;;;;;
>>;Subroutines
>>
>>debounce
>>
>>		movlw		0xff
>>		movwf		outer_delay
>>
>>load_debounce_inner_delay
>>
>>		movlw		0xff
>>		movwf		inner_delay
>>
>>decr_debounce_loop
>>
>>		decfsz		inner_delay,f
>>		goto		decr_debounce_loop
>>		decfsz		outer_delay,f
>>		goto		load_debounce_inner_delay
>>		return
>>
>>end
>>
>>_______________________________
>>
>>	The .hex file is :
>>:020000040000FA
>>:040000000CEF00F011
>>:08001800060EC16EFE0E926E91
>>:10002000FF0E936E000E946E010E801A1AEC00F013
>>:1000300014EF00F0FF0E206EFF0E216E212E1EEF3A
>>:0A00400000F0202E1CEF00F012006B
>>:020000040030CA
>>:08000000FF210E0EFF0181FF3C
>>:00000001FF
>>
>>	When I read the program memory out of the chip, I get:
>>
>>$ picp /dev/tty.KeySerial1 18f252 -rp
>>
>>:020000040000FA
>>:10000000040E0060000E926E9200000E000E0000C2
>>:10001000010C0000000000000000000000000000D3
>>:10002000000000000000000E000000000020006042
>>:100030000000000000000000020E016C0020046EB1
>>:100040000000000E004000000000012E250E0020E0
>>:10005000002023EF00F0020026EF00F0082E24EF2E
>>:1000600000F0052E22EF00F0120037EF00F00150F3
>>:10007000806E1200FFFFFFFFFFFFFFFFFFFFFFFF8C
>>:10070000F9263F0C060C5B0C4F0C660C6D0C7D0C37
>>:10071000070C7F0C6F0C400CFFFFFFFFFFFFFFFF7C
>>:00000001FF
>>
>>	This obviously does not look the same. Is this normal?  Other chips
>>that are working show program memory reads that are different than the
>>.hex file, also.  I know nothing about how .hex files work.
>>	Can anybody help me get my 18f252 to blink? What am I missing?
>>
>>Thanks
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ####@####.####
>>For additional commands, e-mail: ####@####.####
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
> 
> 
> 
> 

Previous by date: 24 Oct 2006 22:13:07 +0100 Re: [gnupic] Cannot get 18f252 to blink, Edward Tiong
Next by date: 24 Oct 2006 22:13:07 +0100 Re: [gnupic] Cannot get 18f252 to blink, Samuel Tardieu
Previous in thread: 24 Oct 2006 22:13:07 +0100 Re: [gnupic] Cannot get 18f252 to blink, Edward Tiong
Next in thread: 24 Oct 2006 22:13:07 +0100 Re: [gnupic] Cannot get 18f252 to blink, Samuel Tardieu


Powered by ezmlm-browse 0.20.