Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Please Help

Status
Not open for further replies.
In that case, put the number into table1

0061076281"

retlw b'00000011' ;display 0
retlw b'00000011' ;display 0
retlw b'00001001' ;display 6
retlw b'00000100' ; display 1
retlw b'00000011' ;display 0
xxxx
xxx
xxx

retlw b'00000100' ; display 1
retlw b'10000000' ;end of number
 
They still use the 6800 here in England... Can't get my head around that one..
Many years ago I played half heartedly with 6800/6802 code.
It made sense to me as it has a similarity (in my mind) to PDP11 code, which was may introduction to low level machine code programming used to write short diagnostic test programs.

Where is England?
It is in the sea, just off the coast of mainland Europe.
It is where whinging Pomms come from.
After a generation or two, whinging Pomms turn into Auzzies, many of whom believe that us remaining Brits are incapable of doing anything.

Sorry for the thread drift.

JimB
 
This is what I have got from tonight.
Till got to get on to that delay.....

Time for bed i think almost 2am....
 

Attachments

  • Assignment2.ASM
    3.9 KB · Views: 241
Its too painful to watch.. You are over thinking your problem... You will be stuck in a init loop forever!!

Here is my take....
Code:
;**************************************************
; Filename: Ass2_2017_Elbobbo.asm (your file name)
; Date:  
; Author:  Elbobbo 
;**************************************************
; Program description:
; Assembly code to output a 10 digit ASCII coded
; student number one character at a time, as Excess-3 code, to 4 LEDs.
; ...
;************************************************************
;
; Directive sets processor type .............................
 list  p=16F84A
 #include "P16F84A.INC"
  
; Set configuration fuses ...................................
 
 __CONFIG _CP_OFF & _WDT_OFF &_PWRTE_ON & _RC_OSC
  
; Code protection off, watchdog timer off, power up timer on, RC Clock
 errorlevel -302 ;No warnings about register not in Bank 0
 
; Variable definitions***************************************
charpos equ 0x18  ; keep position
dly0 equ 0x19  ;
dly1 equ 0x20
dly2 equ 0x21  ;
dly3 equ 0x22 
holding equ 0x23  ; used for subtract
; Set program origin*****************************************
 ORG 0x00
 goto main
; Subroutines **************************************
; Initialise Port B .................................
initalise: 
 bcf  STATUS,RP0   ;Bank select 0
 clrf  PORTB    ;Clear Port B data latches
 bsf  STATUS,RP0   ;Bank select 1
 movlw 0x00    ;
 movwf  TRISB    ;Set port B lines to output
 bcf  STATUS,RP0   ;Bank select 0 
 clrf charpos   ;start at begining
 retlw 0
       
; Student number ASCII table ..............................
snum: addwf   PCL, f
 dt "0061076281",0  ;Student number "null terminated
; Delay timer ......................................
delay4: movlw 4
 movwf dly0   ; about 4 seconds
delaya: call delay1
 decfsz dly0
 goto delaya
 retlw 0
delay1: movlw 1   ; about a second
 movwf dly1
 clrf dly3
 clrf dly2
delayb: nop
 decfsz dly3
 goto delayb
 decfsz dly2   
 goto delayb
 decfsz dly1
 goto delayb
 retlw 0 
       
 ;Place delay subroutine code here
; Main program **********************************************
main:
 call initalise  ; need to call initailise
 andlw 0   ; clear w
loop: 
 movf charpos,w  ; get char position
 bcf STATUS,C  ; make sure clear befor add..
 call snum   ; fetch Character
 andlw 0xff   ; control zero test
 btfsc STATUS,Z  ; all done?
 goto flash
 movwf holding   ; save character
 movlw 0x2d   ; adjust for ascii and Xs3
 subwf holding,w  ; 
 movwf PORTB   ; display
 call delay4   ; view time
 clrf PORTB   ; 
 call delay1   ; off
 incf charpos   ; next char
 goto loop
flash:
 movlw 0xf   ; flash on
 movwf PORTB   ; 
 call delay1   ; flash off
 clrf PORTB   ; 
 call delay1
        goto flash      ; forever..
 
 END
Probably can be done better... But see where I move stuff around...and do a version for yourself.
 
Hey,
I chucked your code into MPLAB and ran it, the only thing it looks like it is just cycling the flashing loop.
Which is weird because when ran its hex file through Real PIC Simulator it works a treat.
I have been trying to muck round with the btfac STATUS, Z step.
 
Hey,
I chucked your code into MPLAB and ran it, the only thing it looks like it is just cycling the flashing loop.
Which is weird because when ran its hex file through Real PIC Simulator it works a treat.
I have been trying to muck round with the btfac STATUS, Z step.
Play all you want.... That works on real hardware and simulation... The andlw 0xff is there to force a zero condition..
 
It seams to cycle from delayb to decfsz dly3 for ever.
When i remove the goto delayb from the code, it cycles through all the numbers.

delayb:
decfsz dly3
goto delayb

I have tried experimenting with cblock, but I am getting no where
I am using a instruction cycle of 50microseconds
 
What clock speed are you using????

you said:
have tried experimenting with cblock, but I am getting no where
I am using a instruction cycle of 50microseconds

cblock is just for the variables..

Trust me.. The code I did was good... It works great for me..
 
I have been given this:
  • Assume the microprocessor’s ‘instruction cycle’ time is 50 microseconds. That is,

    calculate the delays based on the machine cycle time specified above. Actual time is not

    important as the simulator speed may differ from one PC to another.
So i am working off

Machine cycle = 12.5us per cycle * 4 cycles (fetch, decode, execute, store) = 50us per instruction

Therefore at 12.5us per cycle, i am getting 80kHerz
 
Right.... You'll need to adjust the delays

Code:
; Delay timer ......................................
delay4: movlw 4
 movwf dly0   ; about 4 seconds
delaya: call delay1
 decfsz dly0
 goto delaya
 retlw 0
delay1: movlw 14   ; about a second
 movwf dly1
 clrf dly2
delayb: nop
 decfsz dly2
 goto delayb
 decfsz dly1
 goto delayb
 retlw 0
 
I wonder whether Elbobbo might benefit from reading about nested loops for long delays and play a little with the PicList delay code generator here: to better understand how to adjust those times.

John
 
Status
Not open for further replies.

Latest threads

Back
Top