Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[HELP] PIC18F4550 -- C Programming Problems

Status
Not open for further replies.

scdvom

Member level 1
Joined
Feb 8, 2010
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,524
Hi, I got a problems here. Here is my code

Code:
#include <P18F4550.h>

void main (void)
{
TRISB = 0;	//Make port B as output
PORTB = 0xFF;
}

when I check d Logic Analyzer (waveform), how come it just trigered wif pin 5,6, and 7 only. then hw pin 1,2,3,4?? i tot 0xFF is all turning on??

can any help me to solve tis problem. thx
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
15,045
Helped
4,906
Reputation
9,832
Reaction score
4,700
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
127,849
Are all the pins configured to be digital outputs? Most have more than one use and you may for example, have them configured as analog inputs.

Brian.
 

scdvom

Member level 1
Joined
Feb 8, 2010
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,524
erm..no...hw can I configure all to be digital outputs??
thx 4 helping
 

scdvom

Member level 1
Joined
Feb 8, 2010
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,524
hi, Tahmid. thx 4 ur helping again.its work.thx..^^
erm..I got another question here..like I wan to convert decimal form to hex form.can do I make it?

int x
x=3 //actually = 11
y=x //bt y i wish to show "11"...so wat should declare on y??

char y ???

Added after 9 minutes:

sorry..is decimal to binary..
 

scdvom

Member level 1
Joined
Feb 8, 2010
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,524
here is my code...

Code:
void masterStateMachine(void)
{
	unsigned char fbBits, lrBits, masterBits;

	fbBits = fb.controlBits;				//(fb fb)
	lrBits = lr.controlBits;					//(lr lr)
	masterBits = (fbBits<<2)+(lrBits);		//(fb fb)(lr lr)
 	
	/*
	00:Rest
	01:Forward/Left
	10:Reverse/Right
	*/
	
	switch(masterBits)
	{
		case 0: stop(); break;
		case 1: turnLeft(); break;
.
.
.
.

fb.controlBits and lr.controlBits both are either 0,1, or 3..bt when I wanna store inside fbBits nad lrBits...i need to be binary form.

thx 4 helping
 

btbass

Advanced Member level 5
Joined
Jul 20, 2001
Messages
1,897
Helped
438
Reputation
880
Reaction score
287
Trophy points
1,363
Location
Oberon
Activity points
12,861
As far as an unsigned char is concerned, it can only store a binary number????

decimal 3 is stored as 00000011

hex 0x03 is stored as 00000011

It's a matter of interpretation.

PS
Your code doesn't look like a State machine implementation. Looks more like a loop?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top