CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ENC28J60 reg set HELP

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lejm
Guest







ENC28J60 reg set HELP
PostPosted: Sun Jan 17, 2010 8:08 am     Reply with quote

I'm trying to setup 'led config reg' to make one led blink fast and the other one blink slow.

My code look like this:
Code:

#define CS  PIN_D2

void main()
{
 
output_high(CS);
delay_ms(100);
 setup_adc_ports(AN0 |VREF_VREF);
 setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_comparator(NC_NC_NC_NC);
setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_16);
 

output_low(CS);
spi_write(0x5F06); //  SELECT '2' REG BANK
//output_high(CS);
//delay_ms(10);
//output_low(CS);
spi_write(0x5410); // WRITE 'x10' to 14 REG of 2 BANK to point to the 'led config reg'
//output_high(CS);
//delay_ms(10);
//output_low(CS);
spi_write(0x563B); // WRITE UPPER BIT VALUE
//output_high(CS);
//delay_ms(10);
//output_low(CS);
spi_write(0x57A0); // WRITE LOWER BIT VALUE
output_high(CS);

//spi_write(0x214DD0); //write 0x80 to SPI device
}

Code has no effect ;/
Leds are off all the time.

What am I doing wrong?
Ttelmah
Guest







PostPosted: Sun Jan 17, 2010 3:02 pm     Reply with quote

What size value does spi_write take.
What size value are you giving it.....

Best Wishes
lam
Guest







PostPosted: Sun Jan 17, 2010 4:04 pm     Reply with quote

Quote:
What size value does spi_write take.

I have no idea.

As is in the Datasheet of ENC.

Im writing for example spi_write(0x5F06);
to point to the 2'nd bank by writing to the ECON1 register.

spi_write(0x5F06); is equal of
bin (010 11111 00000110)
010 mean that we will Write Control Register
11111 is pointer to the register (in this case ECON1)
00000110 is new value to be written into register.
So im sending 2 bytes.

-------
Is there anyone who work with ENC and is able to give me clear answer ? [;
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 17, 2010 4:42 pm     Reply with quote

Download the CCS manual and look at the allowable size of the
parameter for the spi_write() function. Hint: it's not 16-bit.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
lejm
Guest







PostPosted: Mon Jan 18, 2010 9:19 am     Reply with quote

so how to transmit : 0x5F06
spi_write(0x5F);
spi_write(0x06); ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group