nagkiller
Full Member level 4
- Joined
- Jul 9, 2009
- Messages
- 238
- Helped
- 37
- Reputation
- 74
- Reaction score
- 37
- Trophy points
- 1,308
- Location
- Brazil
- Activity points
- 2,706
Hello.
I'm trying to write some values in eeprom 25AA160, but without success.
Here is the code:
Debug window:
Could you tell me what is wrong???
10x
I'm trying to write some values in eeprom 25AA160, but without success.
Here is the code:
Code:
#include <16F1827.h>
#FUSES NOMCLR, NOBROWNOUT, NOFCMEN, NOSTVREN, NOLVP, NOIESO
#use delay(internal=4MHz)
#use spi (MASTER, CLK=PIN_B1, DO=PIN_B3, DI=PIN_B2, BAUD=1000000, MODE=0, BITS=8, STREAM=PIC)
#define CS PIN_B4
#define LED PIN_B7
// Instruction SET of 25AA160
#define READ 0B00000011 // Read data from memory array beginning at selected address
#define WRITE 0B00000010 // Write data to memory array beginning at selected address
#define WRDI 0B00000100 // Reset the write enable latch (disable write operations)
#define WREN 0B00000110 // Set the write enable latch (enable write operations)
#define RDSR 0B00000101 // Read Status register
#define WRSR 0B00000001 // Write Status register
void main()
{
output_high(CS);
delay_ms(100);
output_low(CS);
spi_xfer(WREN);
output_high(CS);
output_low(CS);
spi_xfer(WRITE);
spi_xfer(0xF7F0);
output_high(CS);
delay_ms(100);
for(;;)
{
delay_ms(100);
output_toggle(LED);
}
}
Debug window:
Could you tell me what is wrong???
10x