Searching \ for '%code problem%' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=code+problem
Search entire site for: 'code problem'.

_Sub string match.
PICList Thread
'code problem'
1997\03\20@201904 by Bill Meadows

picon face
Can anyone please tell me why the following Pic16C84 code doesn't work!
;
count equ 0c
countn equ 0d
countm equ 0e
shift   equ     0f

   org 000
start
   movlw 00           ;set port B
   tris portb         ;           for output
   clrf portb         ;all lines low (8 LED's off)
;
   movlw .9           ;number of
   movwf count        ;          shifts
;
   bcf status, c      ;clear carry flag
   movlw b'00000001'  ;store
   movwf shift        ;      pattern
;
repeat
   movf shift, w      ;get pattern
   movwf portb        ;display pattern
   call delay         ;                slowly
   rlf shift          ;rotate pattern left
   decfsz count       ;count-1 to count register by default
   goto repeat        ;LEDs flash one at a time from right to left
done goto done         ;program never gets to 'done'!
;
delay                  ;Easy PIC'n pause routine(delay works great)

   movlw 0ff          ;m
   movwf countm       ;  to counter
loadn
   movlw 0ff          ;n
   movwf countn       ;  to counter
decn
   decfsz countn      ;decrement n
   goto decn          ;again
   decfsz countm      ;decrement m
   goto loadn         ;again
   return             ;done

Thanks for the help,
Bill Meadows

1997\03\20@212053 by Sarunas Cepulis

flavicon
face
Bill Meadows wrote:
>
> Can anyone please tell me why the following Pic16C84 code doesn't work!
> ;
> count equ 0c
> countn equ 0d
> countm equ 0e
> shift   equ     0f
>
>     org 000
> start

       clrf    portb
       bsf     status,rp0      ;SELECT REG. BANK 1

>     movlw 0            ;set port B
>     tris portb         ;for output

       bcf     status,rp0      ;SELECT REG. BANK 0

{Quote hidden}

Hi,
Try this.
Saras.

1997\03\20@223952 by Andrew Warren

face
flavicon
face
Bill Meadows <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> Can anyone please tell me why the following Pic16C84 code doesn't work!

Bill:

Your code is fine... My guess is that you haven't disabled the
watchdog timer.  Try doing that (or adding a "CLRWDT" instruction
right after the "decn" label) and see if that fixes it.

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
===
=== Custodian of the PICLIST Fund -- For more info, see:
=== www.geocities.com/SiliconValley/2499/fund.html

1997\03\20@231240 by piclist

flavicon
face
Bill Meadows wrote:
>
> Can anyone please tell me why the following Pic16C84 code doesn't work!
> ;
> count equ 0c
> countn equ 0d
> countm equ 0e
> shift   equ     0f
>
>     org 000
> start

       clrf    portb
       bsf     status,rp0      ;SELECT REG. BANK 1

>     movlw 00           ;set port B
>     tris portb         ;           for output

       bcf     status,rp0      ;SELECT REG. BANK 0

{Quote hidden}

Hi,
Try this.
Saras.


'Code problem..bcf,bsf,btfss...'
1997\04\07@040745 by joha1359
flavicon
face
Hi
I have problem bcf,bsf,btfss,btfsc. The problem is that I want to have
a variable bit position in these commands.
       ex      bsf     PORTA,num            ; num is 0,1,2
mpasm comes up with warnings that says that the value is too big and it
will use the least significant bits, but it don't work in mpsim. I use '84
                               thanks
                                              Johan

1997\04\07@043235 by Robert Lunn

flavicon
face
>I have problem bcf,bsf,btfss,btfsc. The problem is that I want to have
> a variable bit position in these commands.
>        ex      bsf     PORTA,num            ; num is 0,1,2

       You cannot have a variable bit position in these commands.  The
       bit field is a fixed value only (it is hard coded into the command
       byte).

       Presumably 'num' in the above example is the name of a variable.
       MPASM is giving you an error because the bit field can only have
       a constant value in the range 0..7, and the constant value of
       'num' is the address of the allocated data byte in memory.

___Bob


'SERIAL CODE PROBLEM'
1997\05\17@173409 by eric naus
picon face
part 0 67 bytes
Attachment converted: wonderland:SERIAL.ASM (TEXT/MSIE) (00002DF9)

1997\05\19@062445 by STEENKAMP [M.ING E&E]

flavicon
picon face
Hi,

You do not call bit_delay after you have found the start bit.  This
causes all 8 data bits to be sampled in rapid succession.

Proposed correction:
.
.
.
start_bit   btfsc      ser_in,2
           goto       start_bit   ;look for start bit
           call       start_delay ;get centre of start bit
           btfsc      ser_in,2    ;look if still low
           goto       start_bit   ;false input start again

==>         call       bit_delay   ;Wait until middle of first data bit

           movlw      8           ;load counter for 8 bits
           movwf      bit_cntr
           clrf       rcv_byte    ;clear recieve byte
recieve     btfss      ser_in,2    ;get bit
           bcf        c,0         ;clear carry if bit is zero
           btfsc      ser_in,2
           bsf        c,0         ;set carry if bit is high
           rrf        rcv_byte,1  ;rotate carry to high bit in recieve
byte

==>         call       bit_delay   ;Wait until middle of next data bit

           decfsz     bit_cntr,1  ;if counter not finished get next bit
           goto       recieve
.
.
.

Hope this helps!
Niki

1997\05\19@125158 by eric naus

picon face
Hi,

Thanks for pointing it out.
Appreciate the quick help.

Regards

Eric naus


At 12:14 PM 5/19/97 GMT+0200, you wrote:
{Quote hidden}


'HELP! R/C Servo Code problems-Can U find problem.'
1998\01\10@113704 by PHXSYS
picon face
I am a beginner and I'll bet one of you servo experts can solve my problem in
about 5 seconds. Undoubtedly I have made a code error.

I am trying to control the position of a R/C servo using a Pot. I am timing
the discharge of a capacitor to determine the pot position. I ran that part of
the program by itself and displayed the results of pot position in binary on
port b, everything worked fine. The leds displayed position from 1-255
(limit=255). When I combined the pot program with a servo program nothing
happens. On power up the servo moves immediately to one position and does not
respond to the pot position. If I ground PIC 16f84 pot position pin nothing
happens unless I reset power where it will stay in a middle position. If I
apply 5 volts nothing happens until a power reset.

BO

I have attached the code, if someone could review and comment I would be able
to get on with my life.

Thankyou   Jon

;*******************************;
;       MAIN ENTRY POINT        ;
;*******************************;
       ORG 0X000
       GOTO START
;*******************************;
;    INTERRUPT SERVICE CODE     ;
;*******************************;
       ORG 0X004
       RETFIE                  ;return from interrupt


;*******************************;
;       SETUP PORTS Etc.        ;
;*******************************;
START
       MOVLW      B'10000111'
       OPTION                  ;set up the OPTION register

       MOVLW      B'00000000'
       MOVWF      0BH              ;Set up the INTCON register

       MOVLW     B'00000000'
       TRIS           PORTA            ;setup port A BITs 0-3 as OUTPUT
       MOVWF     PORTA            ;clear port A

       MOVLW     B'11111111'
       TRIS          PORTB            ;setup port B BITs 0-7 as INPUT

;       MOVLW      080H             ;Setup SERVOS to CENTRE
;       MOVWF      PULSE1S          ;Servo 1 Initial Position
;       MOVWF      PULSE2S          ;Servo 2 Initial Position
;         MOVLW       040H
;         MOVWF       PULSE1PS1
;         MOVWF       PULSE2PS1
;         MOVLW      0C0H
;         MOVWF      PULSE1PS2
;         MOVWF      PULSE2PS2
                               ;*******************************;
                               ;       MAIN LOOP               ;
                               ;*******************************;
                               ;       FIRST  SERVO            ;
                               ;*******************************;
BEGIN   MOVFW    PULSE1S          ;LOAD Pulse Store
            MOVWF    PULSE1           ;LOAD Pulse Counter
            MOVLW     0FAH             ;Load 1ms. counter
            MOVWF     DELAY1           ;Get it into reg
            BSF           PORTA,0          ;Start pulse output
HIMS1   NOP                                    ;Force loop into 4 cycle duty
(even #)
            DECFSZ     DELAY1,F         ;Decriment Counter DELAY1
            GOTO         HIMS1            ;No yet Zero -> Goto HIMS1
HIGH1   NOP                                  ;Force loop into 4 cycle duty
(even #)
            DECFSZ     PULSE1,F         ;Decriment PULSE1
            GOTO        HIGH1            ;Not Yet Zero -> Gotot HIGH1
            BCF           PORTA,0          ;End pulse output
                               ;***********************************;
                               ; EXTEND TO FULL 2 mSEC PULSE WIDTH ;
                               ;***********************************;
            MOVFW      PULSE1S          ;get the register position value
            SUBLW       0FAH             ;subtract it from 250
            MOVWF     PULSE1           ;place the difference in the counter
LOW1    NOP                                ;force loop into 4 cycle duty (even
#)
            DECFSZ     PULSE1,F         ;loop for high part of duty cycle
            GOTO        LOW1             ;while pulse > 0
                               ;***********************************;
                               ; READ INPUT POT B0             ;
                               ;***********************************;
UP_DOWN  CLRF   PULSE1S         ;Clear previous value
                    MOVLW  B'11111110' ;setup port B BITs  as OUTPUT
                  TRIS   PORTB         ;
                     BSF    PORTB,0            ;START CAPACITOR CHARGE
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     MOVLW  b'11111111'        ;Set PortB,0 to input
                     TRIS   PORTB              ;Teach portA
 MEAS1   CLRWDT
                     BTFSS  PORTB,0          ;Test b0 skip if 1
                     GOTO   UP_DOWN
                     INCFSZ PULSE1S,F  ;Inc pulse1s skip if 0
                    GOTO   MEAS1            ;
CLEANUP   MOVLW  0XFF
                     MOVF   PULSE1S,W
                               ;***********************************;
                               ; DUTY CYCLE DELAY LOOP 15 mSEC     ;
                               ;***********************************;
LOOP15  MOVLW      0FH              ;load the value of 15
             MOVWF     DELAY2           ;store it in counter Delay2
DUTY1    MOVLW     0FAh             ;load the value of 250
             MOVWF     DELAY1           ;Store it int the counter delay1
DUTY2    NOP                     ;force loop into 4 cycle duty (even #)
             DECFSZ      DELAY1,F         ;Decriment Delay1
             GOTO         DUTY2            ;if not zero -> Goto DUTY2
             DECFSZ      DELAY2,F         ;Decriment Delay2
             GOTO         DUTY1            ;if not zero -> Goto DUTY1
FINAL     GOTO         BEGIN            ;restart the MAIN Programme loop
;
ERROR_  SLEEP                   ;Hmm if we got here we ha
               END                     ;The End

1998\01\10@114507 by PHXSYS

picon face
I am a beginner and I'll bet one of you servo experts can solve my problem in
about 5 seconds. Undoubtedly I have made a code error.

I am trying to control the position of a R/C servo using a Pot. I am timing
the discharge of a capacitor to determine the pot position. I ran that part of
the program by itself and displayed the results of pot position in binary on
port b, everything worked fine. The leds displayed position from 1-255
(limit=255). When I combined the pot program with a servo program nothing
happens. On power up the servo moves immediately to one position and does not
respond to the pot position. If I ground PIC 16f84 pot position pin nothing
happens unless I reset power where it will stay in a middle position. If I
apply 5 volts nothing happens until a power reset, it may move to one extreme.
At no time does the servo respond to pot position. With power cycle servo will
go from a center position to one extreme, but never to the other.

BO is used to measure the pot and A0 is used to control the servo. I switch B0
from output to input to measure cap discharge.

I have attached the code, if someone could review and comment I would be able
to get on with my life.

Thankyou   Jon

;*******************************;
;       MAIN ENTRY POINT        ;
;*******************************;
       ORG 0X000
       GOTO START
;*******************************;
;    INTERRUPT SERVICE CODE     ;
;*******************************;
       ORG 0X004
       RETFIE                  ;return from interrupt


;*******************************;
;       SETUP PORTS Etc.        ;
;*******************************;
START
       MOVLW      B'10000111'
       OPTION                  ;set up the OPTION register

       MOVLW      B'00000000'
       MOVWF      0BH              ;Set up the INTCON register

       MOVLW     B'00000000'
       TRIS           PORTA            ;setup port A BITs 0-3 as OUTPUT
       MOVWF     PORTA            ;clear port A

       MOVLW     B'11111111'
       TRIS          PORTB            ;setup port B BITs 0-7 as INPUT

      MOVLW      080H             ;Setup SERVOS to CENTRE;       MOVWF
PULSE1S          ;Servo 1 Initial Position
;       MOVWF      PULSE2S          ;Servo 2 Initial Position
;         MOVLW       040H
;         MOVWF       PULSE1PS1
;         MOVWF       PULSE2PS1
;         MOVLW      0C0H
;         MOVWF      PULSE1PS2
;         MOVWF      PULSE2PS2
                               ;*******************************;
                               ;       MAIN LOOP               ;
                               ;*******************************;
                               ;       FIRST  SERVO            ;
                               ;*******************************;
BEGIN   MOVFW    PULSE1S          ;LOAD Pulse Store
            MOVWF    PULSE1           ;LOAD Pulse Counter
            MOVLW     0FAH             ;Load 1ms. counter
            MOVWF     DELAY1           ;Get it into reg
            BSF           PORTA,0          ;Start pulse output
HIMS1   NOP                                    ;Force loop into 4 cycle duty
(even #)
            DECFSZ     DELAY1,F         ;Decriment Counter DELAY1
            GOTO         HIMS1            ;No yet Zero -> Goto HIMS1
HIGH1   NOP                                  ;Force loop into 4 cycle duty
(even #)
            DECFSZ     PULSE1,F         ;Decriment PULSE1
            GOTO        HIGH1            ;Not Yet Zero -> Gotot HIGH1
            BCF           PORTA,0          ;End pulse output
                               ;***********************************;
                               ; EXTEND TO FULL 2 mSEC PULSE WIDTH ;
                               ;***********************************;
            MOVFW      PULSE1S          ;get the register position value
            SUBLW       0FAH             ;subtract it from 250
            MOVWF     PULSE1           ;place the difference in the counter
LOW1    NOP                                ;force loop into 4 cycle duty (even
#)
            DECFSZ     PULSE1,F         ;loop for high part of duty cycle
            GOTO        LOW1             ;while pulse > 0
                               ;***********************************;
                               ; READ INPUT POT B0             ;
                               ;***********************************;
UP_DOWN  CLRF   PULSE1S         ;Clear previous value
                    MOVLW  B'11111110' ;setup port B BITs  as OUTPUT
                  TRIS   PORTB         ;
                     BSF    PORTB,0            ;START CAPACITOR CHARGE
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     NOP                       ;Time to charge
                     MOVLW  b'11111111'        ;Set PortB,0 to input
                     TRIS   PORTB              ;Teach portA
 MEAS1   CLRWDT
                     BTFSS  PORTB,0          ;Test b0 skip if 1
                     GOTO   UP_DOWN
                     INCFSZ PULSE1S,F  ;Inc pulse1s skip if 0
                    GOTO   MEAS1            ;
CLEANUP   MOVLW  0XFF
                     MOVF   PULSE1S,W
                               ;***********************************;
                               ; DUTY CYCLE DELAY LOOP 15 mSEC     ;
                               ;***********************************;
LOOP15  MOVLW      0FH              ;load the value of 15
             MOVWF     DELAY2           ;store it in counter Delay2
DUTY1    MOVLW     0FAh             ;load the value of 250
             MOVWF     DELAY1           ;Store it int the counter delay1
DUTY2    NOP                     ;force loop into 4 cycle duty (even #)
             DECFSZ      DELAY1,F         ;Decriment Delay1
             GOTO         DUTY2            ;if not zero -> Goto DUTY2
             DECFSZ      DELAY2,F         ;Decriment Delay2
             GOTO         DUTY1            ;if not zero -> Goto DUTY1
FINAL     GOTO         BEGIN            ;restart the MAIN Programme loop
;
ERROR_  SLEEP                   ;Hmm if we got here we ha
               END                     ;The End

1998\01\10@170642 by Mike Keitz

picon face
On Sat, 10 Jan 1998 11:34:40 EST PHXSYS <PHXSYSspamKILLspamAOL.COM> writes:

>I am trying to control the position of a R/C servo using a Pot. I am
>timing
>the discharge of a capacitor to determine the pot position.
[...]
>  MEAS1   CLRWDT
>                      BTFSS  PORTB,0          ;Test b0 skip if 1
>                      GOTO   UP_DOWN
>                      INCFSZ PULSE1S,F  ;Inc pulse1s skip if 0
>                     GOTO   MEAS1            ;
>CLEANUP   MOVLW  0XFF
>                      MOVF   PULSE1S,W

As written, there is no way out of the measurement routine except when
PULSE1S overflows to 0.  You don't ever want to go back to UP_DOWN
(taking a new measurement) except as part of the main loop after doing a
servo pulse with the old measurement.  Rewrite it to something like:

meas_lp
       btfss   PORT_B,0                ;When cap has discharged,
       goto    meas_done               ;measurement done.
       incfsz  PULSE1S,f               ;Inc. measured value
       goto    meas_lp                 ;If no overflow, wait
more
       decf    PULSE1S,f               ;Fix overflow value back to
255
meas_done

The "cleanup", whatever it's supposed to do, appears unnecessary.  Make
sure the WDT prescaler is set high enough to guarantee that the WDT won't
run out during the 20 ms main loop.  Then clear it just at the start of
each main loop.  It would help to write the delay, cap measure, etc.
sections as subroutines.  This makes it easier to follow the flow through
the main loop as well as expand the function of the program later.

1998\01\11@111937 by ken

flavicon
picon face
Just out of interest the servo control pulse never goes below about
0.9mS so measuring this part of the input is a waste of resolution if
you want to keep to 8 bits. What I do is have fixed delay of about 875uS
and then I start measuring the input pulse, this gives me 5uS resolution
and a count of FF is about 2.035mS. In the output routine I have the
same fixed delay before I start the variable part. You must keep the
steps as small as possible if you go up to 10uS resolution the servos
will jitter and buzz. If anyone wants my basic input and output routines
email me and I will send them out to you.

Ken.

+-----------------------------+--------------------------------------+
|      Ken Hewitt  G8PWC      |     Email .....kenKILLspamspam.....welwyn.demon.co.uk     |
|      /\/\/\/\/\/\/\/\/      |   Homepage  http://www.welwyn.demon.co.uk   |
+-----------------------------+--------------------------------------+

1998\01\11@130857 by Andy Shaw

flavicon
face
I've also played around with RC pulse a fair bit and the system I use uses
the TMR0 function of a 4Mhz part to time and generate RC pulses. If you use
it with the pre-scaler set to divide by 8 then you end up with 125 ticks
being a millisecond. Using 1.5 ms as the mid point of the RC pulse (and
subtracted on input added on output as described by ken) means that you can
use a value of +-64 to represent the servo position (or whatever). The nice
thing about this sort of range is that you can perform a fair bit of
manipulation of values etc. using only 8 bit arithmetic it is easy to put
together functions/macros to limit things to this range, create deadbands
etc. I've used this system to create simple mixers, and various other
systems that require RC inputs to be combined with real world measurements
before being used to control an RC servo.

just a thought

Andy

{Original Message removed}

1998\01\12@121631 by 'Grif' w. keith griffith

flavicon
face
Ken,,, I'd like a look at your code as well...  I'm a system dba by day,
and for some reason, the pic products have brought some of the fun of
microcomputers back home.  I havent' had this much fun since I got my
altair8080 to do the first 8 bit add and halt!

At 12:58 1/11/98 +0000, you wrote:
>What I do is have fixed delay of about 875uS
>and then I start measuring the input pulse, this gives me 5uS resolution
>and a count of FF is about 2.035mS. If anyone wants my basic input and
output routines
>email me and I will send them out to you.
>
>Ken.




'Grif' N7IVS

1998\01\12@153533 by ken

flavicon
picon face
part 0 669 bytes content-type:text/plainTo save me having to keep mailing this out I ached the code to this
response, its not too big so I hope those not interested in it don't
mind.


Content-Description: rc_samp.asm
Content-Disposition: attachment; filename="rc_samp.asm"
Content-MD5: eb4kQr6Y1Iqc7WdXPXkjEw==
Content-Type: text/plain

Attachment converted: wonderland:rc_samp.asm (TEXT/MSIE) (0000F8D8)

Ken.

+-----------------------------+--------------------------------------+
|      Ken Hewitt  G8PWC      |     Email EraseMEkenspam_OUTspamTakeThisOuTwelwyn.demon.co.uk     |
|      /\/\/\/\/\/\/\/\/      |   Homepage  http://www.welwyn.demon.co.uk   |
+-----------------------------+--------------------------------------+


'HELP! R/C Servo Code problems-(Ken)'
1998\01\13@102812 by PHXSYS

picon face
Ken,
Sorry, I accidently sent the previous message before it was finished. I am a
beginner and don't understand a portion of a timing loop in the sample code
you sent me (which I greatly appreciate). I have been taught that all commands
execute in one instruction except for goto, call, return, which execute in 2,
or a incfsz (or other command) which results in 0. I understood all of your
timing loops except for one, which stated it was a 5us long timing loop.

Time_ip
         btfss    Port_B,pulse_ip      ;(1 instruction)
         goto     end_ip                   ; only executed if 0
         incfsz   ip_pulse,1              ;(1 instruction)
         goto     Time_ip                  ;(2 instruction)
          goto     max_pulse             ; only executed if 0

It seems that the ip_pulse is incremented every 4us. What am I missing?


Jon

1998\01\13@112032 by Michael S. Hagberg

flavicon
face
the btfss Port_B,pulse_ip instruction takes 2 cycles if set and 1 if not
set. the processor replaces the goto statement with a NOP to create the
skip.

michael


{Original Message removed}

'Code Problem... What is wrong?'
1998\01\19@140715 by Radboud Verberne

flavicon
face
Hello EveryOne,

I've written a piece of code... But unfortualy it doen not work right...
The 16c84 communicates with 3 CD4094 IC's. (Serial to parrallel). The error
MUST be in the hef4094 routine, but i can't finft the error... Who can find
the problem?

(-----Cut----)
SendOne
       bsf DATA
       call wait
       bsf CLOCK
       call wait
       bcf DATA
       nop
       bcf CLOCK
       return

SendZero
       bcf CLOCK
       call wait
       bsf CLOCK
       call wait
       bcf CLOCK
       return

hef4094
       movwf txbyte
       movlw 0x07
       movwf bitcount
Sendbit
       btfss txbyte, bitcount  ; Skip next line if bit is set.
       call SendZero           ; Sends a 0
       call SendOne            ; Sends a 1
       decfsz bitcount,1       ; Decrement bitcount, SKip if Zero
       goto Sendbit
      return

(----Cut-----)

main
       movlw 0xFF
       call hef4094
       movlw 0x00
       call hef4094
       movlw 0x00
       call hef4094
       goto main
end

This piece of code should make 8 of the 24 bits high... But when I look at
the outputs of the CD4094 it isn't...
He problably sends one Bit to much or something...
Greetz,
       Radboud Verberne.


ICQ: 918640 (I Seek You)

AX25: NL1DDUspamspam_OUTNL3SMG.NBO.NLD.EU (27.405Mhz)
     PE1RUH@PI8SHB.#NBO.NLD.EU (144.925Mhz)

Yes! I've succeeded my Radio Examenation! My call is PE1RUH!
I've rebuilt a Teletron T813 and i'm most of the time QRV on
145.2125 or 145.7000 (Relais Eindhoven).

S-Mail: Eerste Vijverstraat 6
       5258 HR Berlicum, The Netherlands
Phone:  +31-73-503-4733

"Er is hier niks te doen, maar begin er maar alvast mee..."

1998\01\19@154603 by Michael S. Hagberg

flavicon
face
every time you send a '1' bit it works find, but every time you send a '0'
bit it will then send a '1' bit when it returns from the call.

solution 1. change call's to goto's and return to goto label just after the
goto sendone line.

solution 2. use straightline coding and get rid of the call's and goto's

michael


>Sendbit
>        btfss txbyte, bitcount  ; Skip next line if bit is set.
>        call SendZero           ; Sends a 0
>        call SendOne            ; Sends a 1

1998\01\19@174413 by Greg Maki

flavicon
face
At 07:32 PM 1/19/98 +0100, you wrote:
{Quote hidden}

Radbound,

I believe your biggest problem is trying to use a variable to select the
bit number. BTFSS needs a constant for the bit number so what it does is
use the address (probably truncated to 3 bits) of the variable <bitcount>.
Also, when you call SendZero, it returns and calls SendOne immediately.

You might try:

Sendbit
               rrf     txbyte,f        ;rotate LSB into carry bit
               btfss   STATUS,C        ;is it a 0
                goto   Zero            ;yes, send a zero bit
               call    SendOne ;no, send a one bit
               goto    Nextbit ;go check bit counter
Zero            call    SendZero        ;go send a zero bit
Nextbit decfsz  bitcount,f      are we done?
                goto   Sendbit
               return

I haven't tested this code or optimized it but it should work. Hope this
helps!

Greg Maki

1998\01\19@182505 by TONY NIXON 54964

flavicon
picon face
>hef4094
>        movwf txbyte
>        movlw 0x07
>        movwf bitcount
>Sendbit
>        btfss txbyte, bitcount  ; Skip next line if bit is set.
>        call SendZero           ; Sends a 0
>        call SendOne            ; Sends a 1
>        decfsz bitcount,1       ; Decrement bitcount, SKip if Zero
>        goto Sendbit
>       return

You will never transmit bit 0 using this routine, and it will always
transmit an extra 1 bit if you try to send a 0 bit. Also any new data
that you send will not appear at the outputs of the 4094 until the
next bit send is executed. ie CLOCK = high.

Try this.....

hef4094
     movwf txbyte
     movlw 0x08
     movwf bitcount
Sendbit
     rlf txbyte
     btfss status,carry
     goto send0
     call SendOne
     goto OneLess
Send0
     call SendZero
OneLess
     decfsz bitcount
     goto Sendbit
     return

Also try this for the SendOne/Zero routine.....

     ; Clock bit is normally HIGH, so that previous data is already
     ; at the output gates.

SendZero
     bcf Port(x),DATA    ; send 0 bit
     goto ClkOut

SendOne
     bsf Port(x),DATA    ; send 1 bit
ClkOut
     call wait
     bcf Port(x),CLOCK   ;  strobe data to latches
     call wait
     bsf Port(x),CLOCK    ; send data to output pins
     ; the next instruction depends on how many instructions
     ; are executed before this routine is called again
     ; (may not be needed if clock speed is low)
     call wait
     return


I know you have already tried it, but it's fairly easy to trap
errors like these by using MPSIM or MBLAB simulator and single step
through the code. Another thing that is sometimes hard, but very necessary,
is to make sure the code is compatable with any external devices, or
you may suffer many frustrated hours of fruitless debugging.
This means a close examination of the device data sheet.

Tony

For the beginner....
PicNPoke Multimedia 16F84 Simulator Assembler, and Tutorial.
Now with PicNPlay circuit simulator.
Plus animated Address Mode Tutor.

http://www.dontronics.com/picnpoke.html

1998\01\20@054947 by paulb

flavicon
face
Radboud Verberne wrote:

> SendOne
>         bsf DATA
>         call wait
>         bsf CLOCK
>         call wait
>         bcf DATA
>         nop
>         bcf CLOCK
>         return

> SendZero
>         bcf CLOCK
>         call wait
>         bsf CLOCK
>         call wait
>         bcf CLOCK
>         return

 Presumably DATA and CLOCK are defined as a register,bit combination?
Non-critical: Why are these routines assymetric?  What is that NOP doing
there?  Why do you need "wait" calls anyway (is the CPU too fast)?  Is
DATA initialised as clear in case SendZero is called first?

> hef4094
>         movwf txbyte
>         movlw 0x07
>         movwf bitcount
> Sendbit
>         btfss txbyte, bitcount  ; Skip next line if bit is set.

 How did bitcount get into this line?  You can't use a variable as a
bit index into another variable (register)!

>         call SendZero           ; Sends a 0
>         call SendOne            ; Sends a 1

 Hey!  Since when do you want every zero to be succeeded by a one?

{Quote hidden}

 If you leave it looping all the time, the output states will be
changing so fast you'll never see what they are!  (You forgot the strobe
function just before the loop.)

 How about:

SendByte
       movwf txbyte
       movlw 8
       movwf bitcount
clockit
       movlw ck0dt1            ; default data high
       rlf   txbyte            ; MSB first convention, alter if needed
       skcs                    ; macro
       movlw ck0dt0            ; C bit zero: alter data to low
       movwf serio             ; write DATA, CLOCK low
       iorlw ck1dt0            ; add in CLOCK bit
       movwf serio             ; write DATA, CLOCK high
       andlw ck0dt1            ; clear CLOCK bit
       movwf serio             ; write DATA, CLOCK low
       decfsz bitcount         ; loop 8 times
       return

main
       movlw ck0dt0            ; initialise clock & data values
       movwf serio             ; write DATA, CLOCK low
       movlw 0xFF
       call SendByte
       movlw 0x00
       call SendByte
       movlw 0x00
       call SendByte
       movlw ck0dt0+strobe     ; Strobe
       movwf serio             ; the data
       goto main

 Is that all OK?  By setting the I/O register with a pure write each
time, you can safely ignore read-modify-write problems.  The reload of
W between every I/O write should be adequate time for the CMOS to settle
but if you do need a delay routine, you put the "movwf serio" at the
beginning of it and make sure it doesn't alter W.  The following doesn't
alter W but uses up to three stack locations:

dely16  call dely8
dely8   call dely4
dely4   return

 Cheers,
       Paul B.


'Code problem?'
1999\01\04@152727 by brooksg
flavicon
face
hey, a fresh beginner here -
I am programming a 16c924 and here is a portion of my code pertaining to
my problem ;

OPTREG     equ     0x81
RBPU          equ       7
..
                   bcf     OPTREG,RBPU     ;enable pull-up for switch
...
Now the message that I get after compiling is this..

essage[302] C:\MPLAB40\AY0438.ASM 80 : Register in operand not in bank
0.  Ensure that bank bits are correct.

Now is this something I should worry about or what am I not seeing here?

Thanks for the help. I hope I supplied enough info for the problem.

Gary

1999\01\04@155612 by brooksg

flavicon
face
hey, a fresh beginner here -
I am programming a 16c924 and here is a portion of my code pertaining to

my problem ;

OPTREG     equ     0x81
RBPU          equ       7
..
                   bcf     OPTREG,RBPU     ;enable pull-up for switch
...
Now the message that I get after compiling is this..

essage[302] C:\MPLAB40\AY0438.ASM 80 : Register in operand not in bank
0.  Ensure that bank bits are correct.

Now is this something I should worry about or what am I not seeing here?

Thanks for the help. I hope I supplied enough info for the problem.

Gary

1999\01\04@162046 by Ralph Stickley

flavicon
face
Gary,
To remove the warning message use the following at the top of your file
(only do this after you have verified that the proper bank is properly
selected!:-)

ERRORLEVEL -302                 ;remove message about using proper bank

Even if you have inserted the banksel command, you will still get the same
warning (not an overly intellegent assembler here).  Turn off these warning
messages after you simulate / test your
code. (Turn them back on everynow and then and verify that you are in the
correct bank ).

Also, try to find the file:

#include  p16C924.inc

or similiar - you should not enter the definitions for the on-chip
registers, any errors
you enter here will quickly send you up the wrong creek.

Good luck
Ralph

Gary Brooks wrote:

{Quote hidden}

1999\01\04@170015 by Michael J. Ghormley

flavicon
face
I would also add that I might use this in my code:

#DEFINE         cRBPU           OPTION_REG,7
...
       BCF     cRBPU
...

The "OPTION_REG" is your 16C924.INC's definition for the option register and I
would use it per Ralph's advice.

Michael

* TAKE THE '.NOSPAM' OUT OF MY ADDRESS TO REPLY
**********************************************
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too hard to read anyway!
                                 Groucho Marx
**********************************************

1999\01\04@172028 by evan

picon face
> Gary Brooks wrote:
> I am programming a 16c924 and here is a portion of my code pertaining to
> my problem ;
>
> OPTREG     equ     0x81
> RBPU          equ       7
> ..
>                     bcf     OPTREG,RBPU     ;enable pull-up for switch
> ...
> Now the message that I get after compiling is this..
>
> essage[302] C:\MPLAB40\AY0438.ASM 80 : Register in operand not in bank
> 0.  Ensure that bank bits are correct.
>
> Now is this something I should worry about or what am I not seeing here?

Nothing to worry about, if you've selected the correct RAM bank prior to
line 80.

The RAM in the PIC is located in multiple banks.  Each bank only has 7 bits
for addressing, i.e. a range of 0 to 7F within each bank.  (This is due to
the opcode only allowing 7 bits for the file register address.)  The upper
bit, which selects between the RAM banks, must be set separately in the
STATUS register.

In your code, the assembler simply detected that the file register OPTREG
has a value greater than 7F and thus must be located in bank 1 (or higher,
depending on the processor).  The assembler is simply warning you to ensure
you've explicitly selected the correct RAM bank before addressing the file
register (the assembler has no way of knowing this automatically, thus you
will get this warning whether it's set correctly or not).  And in case
you're wondering, in a PIC with only 2 RAM banks (I'm not familiar with the
'924) Bank 1 is selected by:

       bsf     STATUS, RP0

A small recommendation is to download & use p16c924.inc from Microchip,
which contains standard definitions for all their registers & bits.  Will
save you time and make your code easier to read (and debug) by others on the
piclist.

-Ed V
Agile Controls

1999\01\05@064031 by Caisson

flavicon
face
> Van: Gary Brooks <@spam@brooksgKILLspamspamtdsnet.com>
> Aan: KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU
> Onderwerp: Code problem?
> Datum: maandag 4 januari 1999 21:27
>
> hey, a fresh beginner here -
> I am programming a 16c924 and here is a portion of my code pertaining to
> my problem ;
<Snip>

> Now the message that I get after compiling is this..
>
> Message[302] C:\MPLAB40\AY0438.ASM 80 : Register in operand not in bank
> 0.  Ensure that bank bits are correct.
>
> Now is this something I should worry about or what am I not seeing here?

It's a warning.  You used a register that is not in Bank #0.  If you forgot
to switch-over to the correct bank strange effects could occur.  For
example MOVWF PORTA and MOVWF TRISA are coded exacly the same (don't take
my word for it. check it !).  Only because you write into differtent bank's
the target will be PORT or TRIS ...

Its sort like the message :  "You are leaving your home : Are you sure that
you have got your keys with you ?"

Greetz,
 Rudy Wieser

1999\01\06@132033 by

flavicon
face
{Quote hidden}


'I2C Slave Code Problems'
2000\06\12@113218 by Bobby R. Bramlett
flavicon
face
I have exhaustively searched the PICLIST archives concerning slave mode
implementation
in the 16C6X family and I have not been able to find an answer to my
problem. I am connecting two PICS together and communicating via I2C.  The
master PIC is bitbanging
its data and seems to work properly.  The slave PIC is using its internal
I2C hardware
and interrupts.  I can write to the slave device but when I send a read
command it
grabs control of the SCL line and will not release it.  At multiple points
in the code
I have set the CKP bit of SSPCON.  However the SCL line is not released.  In
my
interrupt routine I check to see if the received address byte has the read
bit set.
If it does then I load SSPBUF with the outgoing data and set the CKP bit of
SSPCON.
Does anyone have code showing how they have utilized the slave mode hardware
to read
data from a PIC?

==============================================
= Bobby R. Bramlett
= Lufkin Automation
= Houston, TX
= (281)988-4419
==============================================

2000\06\12@114236 by Peter Schultz

flavicon
face
Hi Bobby,
I have only HiTech C rutin.
Peter

void init_spi_communication ( void )
{
 TRISC4 = 1;   //SPI Slave In
 TRISC5 = 0;   //SPI Slave Out
 TRISC3 = 1;   //SPI Slave CLK In
 TRISA5 = 1;   //SPI SS Enabled In, used for other purpose then SPI
    SMP = 0;   //SPI slave mode
  SSPEN = 1;   //SPI port pins enabled
  SSPM0 = 0;   //Slave Mode SS pin Disabled
  SSPM1 = 0;
  SSPM2 = 1;
  SSPM3 = 0;
    CKP = 1;   //Clock idle is high
    CKE = 0;   //Data on rising edge
}

void main ( void )
{
 hardware_init();
 initialize ();
 init_spi_communication ();    // Initialization of SPI
 SSPBUF = 0x00;                        // Clear SPI receive buffer
 SSPIE = 1;                      // Enable interrupt on SPI receiving
 PEIE = 1;                             // Enable peripherial interrupt(For
SPI)
 ei();                         // Global interrupt enable
 asm("sleep");                 // Going to sleep
 while (1)
  ;
}

{Original Message removed}


'[PIC]:code problem'
2000\08\12@145019 by Sandy Phelps
flavicon
face
Hi,
This my second program on a PIC. I'm using a 16F877 and having
some trouble getting the right value into w.

Tthis starts with a value already in w such as 'a'.
If w = 'a', I want to replace it with 'x'
If w != 'a' leave as is.
The trouble is the last instruction, movlw  _w puts 0x21 into w.
I set a watch on w and _w and all looks good until the last instruction.
This is probably something elementary but it's got me stuck.
Appreciatte any help.

    movwf     _w            ;save w
    xorlw     0x61          ;compare w to 'a'
    btfss     status,2          goto      send
    movlw    0x78        ; x      movwf    _w          ;restore w with orig or new char

send
    movlw     _w

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\08\12@151315 by Dan Michaels

flavicon
face
At 01:38 PM 8/12/00 -0700, you wrote:
{Quote hidden}

As written here, "movlw" command means "move literal to w",
where literal = an 8-bit constant. 0x21 is probably the
address of your variable _w.

BTW, just a hint - it usually makes code more readable if
you write

"btfss status,Z"  rather than  "btfss status,2"

Also, some people write

"movf _w,0"  and  "movf _w,1"  whereas

"movf _w,w"  and  "movf _w,f"  are much more readable.

best regards,
- danM

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\08\12@153438 by Ing. Jose Eleno Curiel G.

flavicon
face
The last instruction could be:
movfw _W
in order to get the CONTENTS of _W register into W register.
instead of
movlw _W

-----Mensaje original-----
De: Dan Michaels <spamBeGoneoricomspamBeGonespamLYNX.SNI.NET>
Para: TakeThisOuTPICLISTEraseMEspamspam_OUTMITVMA.MIT.EDU <RemoveMEPICLISTspamTakeThisOuTMITVMA.MIT.EDU>
Fecha: Sabado 12 de Agosto de 2000 02:16 PM
Asunto: Re: [PIC]:code problem


{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\08\12@155755 by Dan Michaels

flavicon
face
At 01:38 PM 8/12/00 -0700, you wrote:
{Quote hidden}

BTW, another hint related to choosing names for variables,
and trying to debug code that is not working properly....

Using _w for a variable name can cause some real problems,
because w is the most used register in a PIC. Therefore, in
a program with 100 lines, you might end up with _w or w in
almost every line. If you accidentally type _w instead of
w, or vice versa, somewhere in the program, it might take
months to figure out what the problem is.

Better to use something like temp_w or sav_w - variable names
that are more distinctive.

best regards,
- danM

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\08\12@161555 by Sandy Phelps

flavicon
face
Thanks to Jose for the fix. Using movfw makes it work, however I don't see
that in the list
of instructions. I'm not picky, I'll use it.
Thanks also to Dan Michaels for his suggestions. It is very helpful to have
someone
willing to help a neophyte.
Sandy
{Original Message removed}

2000\08\12@204310 by Bob Ammerman

picon face
"movfw  _w" is not really an instruction.

it is a synonym for "movf _w,w".

(boy is that confusing!)

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
sofftware)

{Original Message removed}

2000\08\12@233833 by Nikolai Golovchenko

flavicon
face
Sandy,

It can be done also like this:

       xorlw 'a'       ;compare to 'a', w' = w ^ 'a'
       btfss STATUS, Z
        movlw 'x'^'a'  ;if not equal, w = 'x' ^ 'a'
       xorlw 'a'       ;if w was equal to 'a', restore it
                       ;if   w  was  unequal  to 'a',
                       ; w = 'x' ^ 'a' ^ 'a'= 'x'

Cheers,

Nikolai

---- Original Message ----
From: Sandy Phelps
Sent: Saturday, August 12, 2000 23:38:33
 To: PICLISTEraseMEspam.....MITVMA.MIT.EDU
Subj: [PIC]:code problem

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\08\13@152638 by Oliver Broad

flavicon
face
movfw is one of the built in 'macro' instructions, that is an instruction
that can also be written in a more general form, in this case movf  <r>,w.
The seemingly useless movf <r>,f (move f to f) can be used to test a
register for zero without affecting w, though I believe it is rarely used.

There is another usefull set, the skip instructions, these expand out to bit
test instructions acting on the status register, for example skpnz skip next
instruction if zero flag not set. There are set-bit and clear-bit
instructions.

A handy trick to remember is that an exclusive-or is reversable so you can
write:

xorlw     0x61          ;compare w to 'a'
btfsc     status,Z
movlw    0x61 ^ 0x78; that's 0x19 but writing the expression is clearer
xorlw    0x61    ;put w back how it was

You may find yourself able to eliminate many gotos that way. This can make
code smaller and  avoids the need for a lot of labels.

It also makes the code isochronous, it always takes the same time to execute
regardless of results.

{Original Message removed}


'[PIC]: Code problem with CCS.'
2002\10\25@152650 by Steve Murphy
flavicon
face
Hi Listers,

I'm working on a problem using CCSs C compiler that has me
at wits end. Below is some minimal C code demonstrating the
actual code. The problem is that whether or not the dhcp_dis_req
function is called from file1.c with Dhcp_req equal to one, or
if it is called from file2.c with Dhcp_req being set to zero,
it always builds a discover packet.

I have tried sending a literal zero from file2.c--it still builds
a discover packet. If I set the discover variable to 0 within
dhcp_dis_req(), ( discovering = 0;) it will build the proper
(i.e. dhcp request) packet.
My suspicion is that this is a manifestation of a bank problem.

Any pointers will be appreciated. Speaking of pointers, I tried
making Dhcp_req a pointer and sending in its address, but
the code generated won't link as it overflows a bank.

Steve
------------------------------------------------

file1.c:
.... // defines, includes and function prototypes

static int Dhcp_req = 1; // I've tried other types and non static/global etc.
int main(void)
{
  ....  //init code etc...

  dhcp_dis_req(Dhcp_req);  // send a DHCP discover to obtain an
                           // IP address. This function is in file3.c

  ....  // main loop now processing incoming packets.

   if(incoming_port == UDP)
  {
        process_udp();    // This function is in file2.c.
  }
} //file1.c

file2.c
void process_udp(void)
{
    switch(udp.port)
    {
         case ECHOPORT:
         {
               process_echo_req();
               break;
         }
         case BOOTPCPORT :
         {
               if(our_IP_address == 0 && eth.MAC_add == our_MAC_add)
               {
                  Dhcp_req = 0;
                  dhcp_dis_req(Dhcp_req);  // Send a DHCP request
                  break;
               }
               // code for dhcp_ACK here.
         }
         default:
         {
              puts("unknown port")
              return;
        }
   }
   return;
} // file2.c

file3.c:
void dhcp_dis_req(int discovering)
{
     if(discovering == 1)
           //build a dhcp  discover packet
      else
           //build a dhcp  request packet
      return;
} // file3.c

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


'[PIC]: Re: Code problem with CCS. (followup)'
2002\10\25@153545 by Steve Murphy

flavicon
face
Listers,
I made an omission in my last post. I am using a 16F877 processor.
and I upgraded CCSs PCM compiler. Sorry about that.

Steve

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


'[PIC]: Code problem with CCS.'
2002\10\25@170544 by Mike Mansheim

flavicon
face
> I'm working on a problem using CCSs C compiler that has me
> at wits end.

Since the code looks straightfoward, you need to see exactly
what the compiler is producing.  It's usually pretty clear to
follow simple variable passing to functions.

> My suspicion is that this is a manifestation of a bank problem.

From what I've seen, CCS goes overboard making sure the correct
bank is selected, so you really need to look at (and/or post
parts of) the list file.

This probably relates to the unseen rest of the program, but is
there any reason not to just call dhcp_dis_req with a literal?
At most, local to whatever function calls seems like it would be
enough.  I realize you said a literal still didn't work, but when
you do get it working, this would save ram.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\10\25@180322 by Steve Murphy

flavicon
face
>
Hi Mike
>
> Since the code looks straightfoward, you need to see exactly
> what the compiler is producing.  It's usually pretty clear to
> follow simple variable passing to functions.
I guess that's what I'll do. This project is to add a dhcp
capability to an already existing TCP/IP stack. I had forgotten
that a list file shows the C code along with the asm. I was
dreading looking at 6KB of straight asm to ferret this one out.
>
> >From what I've seen, CCS goes overboard making sure the correct
> bank is selected, so you really need to look at (and/or post
> parts of) the list file.
OK. I'll check it out. If I can't figure it out maybe I'll post
a bit of it.

>
> This probably relates to the unseen rest of the program, but is
> there any reason not to just call dhcp_dis_req with a literal?
> At most, local to whatever function calls seems like it would be
> enough.  I realize you said a literal still didn't work, but when
> you do get it working, this would save ram.
Yes I had symbolics at first.

Regards,

Steve

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\10\25@181137 by William Chops Westfield

face picon face
Does CCS use a "known zero" register at all?  I am reminded of certain ancient
fortran bugs caused when one managed to overwrite memory that was supposed to
be holding constants...

BillW

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\10\27@154518 by Steve Murphy

flavicon
face
>
> Does CCS use a "known zero" register at all?  I am reminded of certain ancient
> fortran bugs caused when one managed to overwrite memory that was supposed to
> be holding constants...
I couldn't find any reference to that Bill. Thank you and Mike M. for the
thoughts. What I ended up doing was making the function take no arguments
and make the flag global. That overflowed the 8K ROM (why??) so I sliced
and diced, plus made the flag and some other 1 bit instead of hoggy
8 bitters. Now I have all of 153 bytes of ROM left to inplement the
DHCP ACK packet and IP address write. Piece of cake... Right? :-0

Regards,

Steve

>
> BillW
>
> --
> http://www.piclist.com hint: The list server can filter out subtopics
> (like ads or off topics) for you. See http://www.piclist.com/#topics
>
>

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspammitvma.mit.edu with SET PICList DIGEST in the body



'[SX] Practical SXB Book Code Problems'
2008\02\16@164249 by DigitalDjn/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, DigitalDj wrote:

I have been playing around trying to learn more of the code for the SX and have run across a snag in the Practical SX book. I have typed this code in but I get nothing. I tried searching the forum because I had read at one time there was some typos in Jon book. So I wanted to see if I was doing something wrong or there was an error in the book.



' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
 
Led Blinky 3

' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
 
DEVICE          SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ            4_000_000

' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------

Led  Pin RB.0
 
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------

IsOn  Con  1
IsOff  Con 0
 
' -------------------------------------------------------------------------

' Variables
' -------------------------------------------------------------------------

' =========================================================================
 PROGRAM Start
' =========================================================================
 
Start:
Do
 Led = IsOn
 Pause 500
 Led = IsOff
 Pause 500
Loop

Thanks,
Kevin

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=250589
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

2008\02\16@170637 by robotworkshopn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, robotworkshop wrote:

Hello,
One thing that I don't see in your code is where you define the pin as an output.  If it
isn't defined as one you won't see any change in the LED.

Robert
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=250589#m250593
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

2008\02\16@173106 by JonnyMacn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote:

Indeed you have a typo, Kevin; I just checked a hard-copy and you omitted the OUTPUT specification for the LED pin.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=250589#m250598
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

2008\02\16@174336 by DigitalDjn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, DigitalDj wrote:

AH HA! I didn't catch that! That was a simple mistake on my part. I do really like your book and can't wait until it is done. Very well written and easy for the newbie if he makes sure to read everything  :smilewinkgrin:  so output changes it so that what is in the constant specifies output.

Thanks,
Kevin
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=250589#m250603
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...