gnupic: first attempt flops


Previous by date: 15 Jun 2006 03:50:27 +0100 Re: [gnupic] How do I set configuration bits for 18f252 in gpasm?, David Froseth
Next by date: 15 Jun 2006 03:50:27 +0100 Re: [gnupic] first attempt flops, Robert Pearce
Previous in thread:
Next in thread:

Subject: first attempt flops
From: "Maxim Wexler" ####@####.####
Date: 15 Jun 2006 03:50:27 +0100
Message-Id: <a0811460606141950y29565ca1m71e1636ca3ad24e4@mail.gmail.com>

Hi group,

I finally got everything setup with an Olimex PG2C serial programmer on my
ubuntu box and tried my first stab at programming a pic.

I found a very simple program called Toggle

booyah@ubuntu:~/docs/pic/toggle$ cat Toggle.asm
; *******************************************
;       This program for the PIC16F874 solves the following program
;       specification:
;       1.      Have the processor toggle Port A <4> repeatedly.
; *******************************************
;
;    Filename:      Toggle.asm
;    Date:          31 January 2005
;    File Version:  1
;
;    Author:        CDR Charles B. Cameron, USN
;    Company:       United States Naval Academy
;
;
; *******************************************
;
;    Files required
;
;                  p16f874.inc
;
; *******************************************

;    Notes:
;       This program initializes PORT A <4> to 0.  It then enters
;       a perpetual loop, toggling the value of A<4> each time.
; *******************************************


        list      p=16f874            ; list directive to define processor
        #include <p16f874.inc>        ; processor specific variable
definitions

        __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC &
_WRT_ENABLE_ON & _LVP_OFF & _CPD_OFF

; '__CONFIG' directive is used to embed configuration data within the .asm
file.; The labels following the directive are defined in the 16f874.incfile.
; See the data sheet for additional information on the configuration word.

; The particular choice given above turns code protection off, watch dog
timer off,
; brown-out reset disabled, power-up timer enabled, HS oscillator mode
selected,; flash program memory write disabled, low-voltage in-circuit
serial programming; disabled, and data EE memory code protrection off.
Other choices
; might be useful in certain circumstances.  For example, if the watchdog
timer
; were in use, replacting _WDT_OFF with _WDT_ON would be appropriate.


;***** VARIABLE DEFINITIONS
; Bits within PORTA
ToggleBit               equ     B'00010000'     ; Designates bit 4 of Port
A.
                                                                ; This is an
open-drain output bit, so
                                                                ; a pull-up
resistor is needed.
TRISAMask               equ     B'11101111' ; Make bit 4 of PORT A an
output.
                                                                ; Leave the
rest as input bits.
ADCON1InitMask  equ B'00000110' ; Make all PORT A bits digital, not analog


; *******************************************
        ORG     0x000                           ; Start with the processor's
reset vector
        clrf    PCLATH                          ; Ensure page 0 is used
        goto    main                            ; Go to beginning of program


main
; *******************************************
; Initialize registers as required
; *******************************************

        bcf     STATUS,RP0                              ; Select Bank 0
        bcf     STATUS,RP1

        clrf    PORTA                           ; Initialize Port A by
clearing the output latches.


; *******************************************
; Switch to Bank 1 and continue doing initializations.
; *******************************************

        bsf             STATUS,RP0                      ; Select Bank 1

        movlw   TRISAMask                       ; Initialize direction pins
for Port A using TRISA.
        movwf   TRISA
        movlw   ADCON1InitMask          ; Initialize the ADCON1 register to
control which
                                                                ; Port A
pins use analog inputs.
        movwf   ADCON1

        bcf             STATUS,RP0                      ; Revert to Bank 0

;main()
; This is the main program.  It does only one thing:  toggle
PORTA<togglebit>

loop
        movlw   ToggleBit
        xorwf   PORTA,f
        goto    loop                            ; Repeat ad infinitum
; *******************************************




        END                       ; directive to assembler:  this is the end
of the program

And it compiles without error:

booyah@ubuntu:~/docs/pic/toggle$ cat Toggle.hex
:08000000018A2802128313030185168330EF0085D5
:060008003006009F128330100685280B8A
:012007003F3267
:00000001FF

Then I got this:

booyah@ubuntu:~/docs/pic/toggle$ picprog --burn --input Toggle.hex -p
/dev/ttyS0 -d pic16f874
Picprog version 1.8.1, Copyright (c) 2006 Jaakko Hyvätti <
####@####.####
Picprog comes with ABSOLUTELY NO WARRANTY; for details
type `picprog --warranty'.  This is free software,
and you are welcome to redistribute it under certain conditions;
type `picprog --copying' for details.

Device pic16f874, program memory: 4096, data memory: 128.
CPU clock speed: 930 MHz
Burning program memory,/dev/ttyS0:PIC programmer missing or chip fault
/dev/ttyS0:0000:unable to read pic while programming

The chip is brand new from Digi-key, never been programmed before. I know
the port is OK cuz I've used it with an external modem, minicom works and I
can scope the TxD line when I send keyboard input through the port.

Anybody see what's wrong here?

-Maxim

Previous by date: 15 Jun 2006 03:50:27 +0100 Re: [gnupic] How do I set configuration bits for 18f252 in gpasm?, David Froseth
Next by date: 15 Jun 2006 03:50:27 +0100 Re: [gnupic] first attempt flops, Robert Pearce
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.