8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
nicholastyc
Mon May 12 2008, 11:28PM
 User Offline
Registered Member #7707
Joined: Wed May 07 2008, 07:13PM

Posts: 38
Thanked 1 time in 1 posts
Hi, Ajay, if u r there...or anyone else...
i am using pic12f629 ... which has 5 I/O and 1 always input GP 3,
i was trying to simulate the I/O setting in MPLAB IDE v7.3
this the code below...
BSF STATUS,5 ; go to bank 1
MOVLW b'00111000'; setting 3,4,5 input, 0,1,2 output
MOVWF TRISIO;
BCF STATUS,5; go back to bank 0
MOVLW 00h ; clear GPIO
MOVWF GPIO;

my problem is, wat i saw from the simulation mode, monitor on the TRISIO , i found that my TRISIO is always 0x08 instead of 0x38 (supposed like this 0x38) !!! i tried many combination again, its only changing the last four bit. why i cant change the bit 4 and bit 5 to input? please HELP....................................very frustated....

Back to top


Ajay
Tue May 13 2008, 03:34PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3375
Thanked 616 times in 583 posts
when you write 1 to GPIO bits then that GPIO becomes input port, so whatever is there on the input will be read while reading GPIO register.

In your case (in simulator) inputs are open and not connected to anything so ports (3,4,5) must read 0. Where as GPIO bit 3 will always read 1 (read datasheet for more information). and when MCLREN = 1 then GPIO bit 3 will always read 0.

Please read datasheet carefully.

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top



This post has been thanked 1 time
nicholastyc
Tue May 13 2008, 05:06PM
 User Offline
Registered Member #7707
Joined: Wed May 07 2008, 07:13PM

Posts: 38
Thanked 1 time in 1 posts
so in this case , my port setting is correct?
i wan my GPIO3,4,5 as inputs and GPIO 0,1,2 as outputs. i read on the datasheet before i post. because i don understand on the MPLAB SIM, cos it never shows on the TRISIO that my GPIO 4,5 are the inputs. now u clear my mind.

thanks for your information.
Back to top


Ajay
Wed May 14 2008, 02:27PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3375
Thanked 616 times in 583 posts
check the file registers, it will atleast show the value you are storing in TRISIO.

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


nicholastyc
Wed May 14 2008, 06:49PM
 User Offline
Registered Member #7707
Joined: Wed May 07 2008, 07:13PM

Posts: 38
Thanked 1 time in 1 posts
HI AJAY,
the trisio never show my GPIO 4 and 5 as input.

i just cant understand why..

my code
ORG 0x00
BCF STATUS,RP0;
MOVLW 00h ;
MOVWF GPIO;
BSF STATUS,RP0 ;
MOVLW 38h;
MOVWF TRISIO;
BCF STATUS,RP0;
then will go to main...

thanks..please correct my code if there is any problem..
Back to top


 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems