Discussion in "8051 Discussion Forum" started by    Help    Dec 8, 2008.
Thu Feb 19 2009, 10:47 pm
I like this thread so much!!

AJAY!! you are so cool men!!

I also need help though..

About my thesis, please see my post

http://www.8051projects.net/forum-t18517.html on this link

Fri Feb 20 2009, 01:53 am
DavesGarage! Thanks for the help
Fri Feb 20 2009, 03:48 am
You are most welcome!

Soon we will have a tutorial page for this topic...

Stay tuned...

-Dave
Fri Feb 20 2009, 03:47 pm
you can see dave is working continuously on his PC to finish the tutorial
Sat Feb 21 2009, 08:53 am
Greetings Everyone,
I would like to have some inquiries regarding PIC18F4550..
I found a header file on the MCC18 compiler h lib folder, p18f4550..
Is this the header file that contains the register of PIC18F4550?

If so, how do I use this registers on a program..
Somehow, I did.. I found this code on MAXUSBLAB10 at maxim website which
uses LPC as MCU..

originally, the code goes like this with SSPDR, SSPSR, SSP_BSY

void Hwreg(BYTE reg, BYTE val)	// write a host register
{
HSSEL_LO
SSPDR = reg+0x02;			// command byte into the FIFO. 0x02 is the write bit
SSPDR = val;				// data byte into the FIFO
while(SSPSR & SSP_BSY) ;	// hang until BUSY bit goes low
HSSEL_HI
}


This is how I revised it using SSPBUF.. also, regarding the way I changed it, was it ok if I removed "hang until busy bit goes low" part?

void Hwreg(BYTE reg, BYTE val)	// write a host register
{
HSSEL_LO
SSPBUF = reg+0x02; // command byte into the FIFO. 0x02 is the write bit
SSPBUF = val;	   // data byte into the FIFO
HSSEL_HI
}


the SSPBUF is declared in the header as

extern volatile near unsigned char       SSPBUF;


But, it return an error (syntax error) on SSPBUF..

Whats wrong?
Sun Feb 22 2009, 12:24 am
i am waiting for a reply here..

:-|
:-s

Sun Feb 22 2009, 06:21 am

i am waiting for a reply here..


If you are waiting and not reading, then you are doing something wrong. I believe people here will help you if they know something about what you are doing, otherwise they cannot. I have never used a PIC processor, and don't have the time to read the data sheet right now, but I'm sure if you read the data sheet, you will find the answers to what you are confused about.

Also, it would be helpful if you described what development environment you are using: the compiler, assembler, host platform, etc...

All of these things will help the person that decides to help you...

Remember, the people that help you are doing so out of the goodness of their heart; because they want to be nice - They are using their time to help you. They deserve some respect. If you want them to devote their time and effort towards your project, you can hire them and pay them as consultants. Otherwise, please be polite...

-Dave

PS - posting your questions here, along with the answers you receive, can not only help you, but others that might have similar problems - Just like this thread has apparently helped you...Just a thought...
Please stop emailing me at my work. Respect that this is where I work, and they pay me to work on their projects, not yours...Please confine your requests to this forum. Thanks, DavesGarage
Sun Feb 22 2009, 07:47 am
im sorry if I sounded impolite lately..

It wasn't what I think I meant it to be.
My apologies..

This is taken from the PIC18F4550 Datasheet

19.3.3 ENABLING SPI I/O
To enable the serial port, SSP Enable bit, SSPEN
(SSPCON1<5>), must be set. To reset or reconfigure
SPI mode, clear the SSPEN bit, reinitialize the SSPCON
registers and then set the SSPEN bit. This configures
the SDI, SDO, SCK and SS pins as serial port pins. For
the pins to behave as the serial port function, some must
have their data direction bits (in the TRIS register)
appropriately programmed as follows:
• SDI is automatically controlled by the SPI module
• SDO must have TRISC<7> bit cleared
• SCK (Master mode) must have TRISB<1> bit
cleared
• SCK (Slave mode) must have TRISB<1> bit set
• SS must have TRISA<5> bit set
Any serial port function that is not desired may be
overridden by programming the corresponding data
direction (TRIS) register to the opposite value.



Here is how we programmed it.

//initializing SPI operation
//SSPSTAT=11xxxxxx;
SSPSTATbits.SMP=1;
SSPSTATbits.CKE=1;

//SSPCON1=xx110000;
SSPCON1bits.SSPEN=1;
SSPCON1bits.CKP=1;
SSPCON1bits.SSPM3=0;
SSPCON1bits.SSPM2=0;
SSPCON1bits.SSPM1=0;
SSPCON1bits.SSPM0=0;

//control bits specified

//enabling I/O
//SDO must have TRISC<7>
 bit cleared
TRISCbits.TRISC7=0;

//SCK must have TRISB<1>
 bit cleared.
TRISBbits.TRISB1=0;

LATBbits.LATB1 = 1;
LATBbits.LATB0 = 1;

SSPBUF=00100110;


are we missing something else?
Sun Feb 22 2009, 07:56 am
We can also simplify the initialization code above as.

SSPSTAT=0b11000000;
SSPCON1=0b00110000;


or

SSPSTAT=0xC0;
SSPCON1=0x30;


is it ok if we do this??
Mon Feb 23 2009, 05:57 pm
eljun, Please start your thread in "PIC Microcontroller Discussion forum"

And there is already a discussion going on regarding USB Flag to USB Flash copy. I think you better go through it. I think its in "Project Help" forum.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am