[SOLVED] i CAN'T BELIEVE IT THIS ACTUALLY WORKS !

Status
Not open for further replies.

techristian

Member level 1
Joined
Apr 3, 2013
Messages
41
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Windsor, Ontario
Activity points
1,611
I still haven't figured out the banking and TRIS command, but somehow the program listed below actually works ! I will post a video to youtube of my first running PIC project but I'm not sure if I can put links up here.

Nevertheless , it is kludgy but the code is entirely mine. It counts in HEX from 0 to 15 on a SINGLE 7 segment display.

To answer the question "What was wrong before?"

1) Still not sure about the TRIS implementation but the above code works. Not sure about the banking either!
2) One big thing is the PAUSE routine that I wrote. The original delay was way too short and the LEDS weren't even lighting up.

So if I count clock cycles in my PAUSE subroutine I might actually figure out my CLOCK FREQUENCY !

DAN
 
Last edited:

It is unsettling to think how often we fix something and we don't know just how we did it.

We want to know, because otherwise it means the same problem could show up in another project.
 

It is unsettling to think how often we fix something and we don't know just how we did it.

We want to know, because otherwise it means the same problem could show up in another project.
Yes but seeing it working gives strength and morale to go on. It also gives a basis to try different things around the working way and makes easier to understand and shortens the path to the target. But enough time should be spent on it. Otherways the upcoming surprises may result to give-up
 

Code:
start movlw b'00000000'	 ;MOVE ZERO TO ACC "W"orking register
BANKSEL 1
TRIS 7
BANK1 is where TRIS register. BANKSEL 1 command is selecting BANK1. BANKSEL is a command which automatically select the page where register is. . TRIS 7 moves value of W to TRIS 7. It sets portC direction, making them all output.So how can you say that,
I still haven't figured out the banking and TRIS command
The next line is unnecssary. It is repetition because W is already zero. Secondly you are changing it to
movlw b'01110111'
After that whole program is executed in BANK0 changing portC bits as required eiher setting high or low..
 

The next line is unnecssary. It is repetition because W is already zero. Secondly you are changing it to
movlw b'01110111'

This line of code is actually the BIT PATTERN required to display the number ZERO on my 7 segment display. Yes it is required. The next one is one, then two,etc.

I have since found a better way to implement this using BRW and tables.

Dan
 

Code:
start movlw b'00000000'	 ;MOVE ZERO TO ACC "W"orking register






BANKSEL 1
TRIS 7

movlw B'00000000' ; This is repetition I was taking about
Here, in First line W is cleared.
start movlw b'00000000' ;MOVE ZERO TO ACC "W"orking register
Then again it is repeated althoug W register is not changed between lines.
movlw B'00000000' ; This is repetition I was taking about
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…