Hey Joe,
I should note that the last time you and I tried to help someone together, we got locked up and whipped ... we better tread carefully here
http://www.picbasic.co.uk/forum/showthread.php?t=6783
Hey Joe,
I should note that the last time you and I tried to help someone together, we got locked up and whipped ... we better tread carefully here
http://www.picbasic.co.uk/forum/showthread.php?t=6783
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi Paul and Joe,
Thank you so mush for replying my post. I am totally new to this PIC16C745, i have got the project from my teacher which is totaly new to me, it is nothing related to my course of study. I am in the process of learning. Please give me your guidance.
I have made some changes to the code but it is still not working . Can you help me to check?
The code is :
AIN org 00000030h
Start
bsf STATUS,RP0 ; select bank1
movlw b'00000110' ; Set pins PORTB 1,2 as Input
movwf TRISB ;
bcf STATUS, RP0 ; go back to Bank 0
ON
btfss PORTB,1 ; Has S1 been press? (Normally high,goes low when pressed.)
goto ON ; No, go back check again
movlw b'00000001' ; move it from register 1 to w.
movwf PORTB ; move it to PORTB to light up the LED
OFF
btfss PORTB,2 ; Has key been press? (Normally high, goes low when pressed.)
goto OFF ; No, check again
movlw b'00000000' ; move it from register 1 to w.
movwf PORTB ; OFF the LED
end ; directive indicates end of code
Thank you Paul and Joe so much . I look forward to hearing from you.
Is this all of your code or is it a snippet (in post above)? I ask because you have no list, includes, or CONFIG at the start. Inside the Microchip folder (from the MPLAB install), you should be able to find a template for the 16c745. I would suggest using this as the outer shell and put your stuff inside. Further, because the PIC you picked is quite "fancy", you should make it blink an LED first to ensure it is even running. Your program is not difficult, but you should start even simpler than you are otherwise you do not know if your problem is a logic issue, a hardware issue, a register issues, etc.
Try to blink your led first
Oh, if your code is complete, you lost the wrap around to return to Start. Your code would just run off into no-where and execute any code left in your PIC (should it be the windowed version)
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi Paul,
I did include list and # include and CONFIG in my code .
list p=16c745 ; list directive to define processor
#include <p16c745.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _E4_OSC
But yet with this, my code is not working.Can you help me. I did like what you said do the simple one first ( blink the LED only ) but it is not working either . Here is my code : for binkling one.
list p=16c745 ; list directive to define processor
#include <p16c745.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _E4_OSC
MAIN org 00000030h
bsf STATUS,RP0 ; select bank1
movlw b'00000000' ; Set pins PORTB 1,2 as Input
movwf TRISB ;
bcf STATUS, RP0 ; go back to Bank 0
Start
movlw b'00000001' ; move it from register 1 to w.
movwf PORTB ; move it to PORTB to light up the LED
movlw b'00000000' ; move it from register 1 to w.
movwf PORTB ; OFF the LED
goto Start
Can you help me with the code cause this Fridat is my dateline.
Thank you so much
>>I did like what you said do the simple one first ( blink the LED only ) but it is not working either
Did the LED not light or did it stay on?
What crystal are you using?
Do you have a schematic?
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Yes, We were spanked ! I think this poor kid is going to have to repeat this class, I just looked at the .lst file for a simple "Blinky" and it was 57k file size, I have just downloaded Section 29 from Microchip website.
Christina, here is a forum from Microchip, where they speak assembly, and apparently C as well.:
http://forum.microchip.com/tt.aspx?forumid=-2
Last edited by Archangel; - 13th September 2007 at 09:00.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Thank you Joe for the link.
HI Paul
I use the 6 MHZ crystal. I did draw the schematic digram but i do not have a sofware to draw the schematic , so i use free hand.
Let me expalain how i connect .
the PIC16C745have 28 pins
connect pin 8 and 19 to the ground
pin 20 to +5 V
pin 21 connnect to a resistor and Led then + 5 V
pin 21 _______(Resistor)____(Led)___ +5V
pin 22 connect reisistor ( also the resistor connect to the ground ) + then the switch and follow by + 5V
(ground)
^
I
I
pin 22.______Resistor__(switch)___(+5V)
pin 23 connect reisistor ( also the resistor connect to the ground ) + then the switch and follow by + 5V
(ground)
^
I
I
pin 23.______Resistor__(switch)___(+5V)
And the cystal have got 4 pins
Pin no 7 to the ground
pin 8 to pin 9 of PIC16C745
pin 14 to the 5V
This schematic is tofor match for :
AIN org 00000030h
Start
bsf STATUS,RP0 ; select bank1
movlw b'00000110' ; Set pins PORTB 1,2 as Input
movwf TRISB ;
bcf STATUS, RP0 ; go back to Bank 0
ON
btfss PORTB,1 ; Has S1 been press? (Normally high,goes low when pressed.)
goto ON ; No, go back check again
movlw b'00000001' ; move it from register 1 to w.
movwf PORTB ; move it to PORTB to light up the LED
OFF
btfsc PORTB,2 ; Has key been press? (Normally high, goes low when pressed.)
goto OFF ; No, check again
movlw b'00000000' ; move it from register 1 to w.
movwf PORTB ; OFF the LED
end
You did not answer
Did the LED light up in your blink test?
Is your 745 windowed or are you burning new PICs each time?
On the diode, which end (anode or cathode) is connect to 5V?
Do you have an Oscilloscope? [EDIT] I have never used a four pin Xtal so I cannot comment on its correctness. If you have a scope, it would be easy to find out.[/EDIT]
you say "btfsc PORTB,2 ; Has key been press? (Normally high, goes low when pressed.)"
but you described the opposite - normally low and high when pressed. If it truly is opposite your program flies past this routine and then off into the ether. You would never see the light blink at 24MHz clock speed. You need to have a way to either send the program back to top (e.g., goto START) or a way to stop the controller from running away (e.g., goto $)
I beg you to make your LED blink first ... the rest is trivial after that.
Last edited by paul borgmeier; - 13th September 2007 at 10:11. Reason: Add Xtal comment
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hello,
I too am not an assembly language user but shouldn't there be some sort of delay (250ms at least)after the LED is turned on and another delay (250ms) after it is turned off so you can actually see the LED changing states?
BobK
Just my 2 cents,
Never seen a 4 pins crystal or resonator, maybe she's using an oscillator, not a crystal.
Then we should know if the config is right for that.
BTW Can we use oscillator ???
Also, maybe someone familiar with this PIC can make a very small program using PBP and send the hex file to Christina to validate the circuit she's using.
J-P
Last edited by GrandPa; - 13th September 2007 at 21:56.
Last edited by GrandPa; - 14th September 2007 at 05:45.
Bookmarks