Hi,
I managed to connect XMEGA-A1 Xplained and ENC28J60-H boards, but I encountered a problem when I tried to set XMega frequency to 32 MHz (internal RC)- ENC28J60-H board stopped working, well at least responding.
With internal RC at 2MHz everything works fine; ENC28J60-H SPI can work up to 20 MHz (according to Datasheet). Even when I prescaled SPI down to 1MHz (with 32MHz clock) ENC28J60-H board doesn't respond.
I used this code to enable 32MHz:
Code:
OSC.CTRL = OSC_RC32MEN_bm;
//Wait for internal oscillator to stabilize
while ( !(OSC.STATUS & OSC_RC32MRDY_bm) );
//Disable change protection for clock
CCP = CCP_IOREG_gc;
//Change clock control register
CLK.PSCTRL = 0x01;
CCP = CCP_IOREG_gc;
//Change clock control register
CLK.CTRL = CLK_SCLKSEL_RC32M_gc;
//Choose clock source
OSC.PLLCTRL=0x00;
OSC.PLLCTRL|=0x80
Any ideas?
Thank you in advance!! |