Hi Leute Ich hänge fest und komm auf den kleinen Fehler nicht drauf:
Ich hab dieses Programm geschreiben bzw. wollte es mal ausprobieren:
#include <18F4550.h>
#include "usb_bootloader.h"
#Fuses
NOPROTECT,NOBROWNOUT,NOPUT,NOPBADEN,HSPLL,PLL5,VREGEN,USBDIV,WRTB,NOLVP
#use delay(clock=20000000)
#include "icons.h"
//#include "icon_off.h"
#INT_SSP //I2C or SPI activity
#INT_BUSCOL //Bus Collision
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#include "24256.c"
main()
{
unsigned int16 i = 0;
init_ext_eeprom();
for(i=0; i<128; i++)
write_ext_eeprom(i, cygwin_icon[i]); //byte 0-127
for(i=0; i<128; i++)
write_ext_eeprom(i+128, flash_icon[i]); //byte 128-255
for(i=0; i<128; i++)
write_ext_eeprom(i+256, outlook_icon[i]); //byte 256-383
// for(i=0; i<72; i++) write_ext_eeprom(i+384, Dog_row1[i]); //offset
= 384, byte 0-71
// for(i=0; i<72; i++) write_ext_eeprom(i+456, Dog_row2[i]);
// for(i=0; i<72; i++) write_ext_eeprom(i+528, Dog_row3[i]);
// for(i=0; i<72; i++) write_ext_eeprom(i+600, Dog_row4[i]);
// for(i=0; i<72; i++) write_ext_eeprom(i+672, Dog_row5[i]);
// for(i=0; i<72; i++) write_ext_eeprom(i+744, Dog_row6[i]);
// for(i=0; i<72; i++) write_ext_eeprom(i+816, Dog_row7[i]);
// for(i=0; i<72; i++) write_ext_eeprom(i+888, Dog_row8[i]);
for(;;){
}
}
Mein Problem ist nun, dass am EEPROM nix drinnen steht!
Harwaremäßig hab ich ein 20MHz Quarz mit PLL (USB) das heißt ich hab
einen internen Takt von 48Mhz.
Ich glaub es stimmt was nicht mit der Taktfrequenz aber ich komm nicht
drauf!
Bitte hilfe
Ich verwende auch einen Bootloader vielleicht liegts auch an den
Interrupts oder Config Bits!
Ich steh an bitte hilfe:
Angefügt hab ich noch 24256.c weil die ja wichtig ist für das EEPROM.
SDA und SCL hängen natürlich richtig am PIC und EEPROM!
Anbei findet ihr noch die include 24256.c:
///////////////////////////////////////////////////////////////////////////
//// Library for a 24LC256 serial EEPROM ////
//// ////
//// init_ext_eeprom(); Call before the other functions are used ////
//// ////
//// write_ext_eeprom(a, d); Write the byte d to the address a ////
//// ////
//// d = read_ext_eeprom(a); Read the byte d from the address a ////
//// ////
//// The main program may define eeprom_sda ////
//// and eeprom_scl to override the defaults below. ////
//// ////
///////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996,2003 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS C ////
//// compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, reproduction ////
//// or distribution is permitted without written permission. ////
//// Derivative programs created using this software in object code ////
//// form are not restricted in any way. ////
///////////////////////////////////////////////////////////////////////////
#ifndef EEPROM_SDA
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#endif
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#define EEPROM_ADDRESS long int
#define EEPROM_SIZE 32768
void init_ext_eeprom()
{
output_float(EEPROM_SCL);
output_float(EEPROM_SDA);
}
void write_ext_eeprom(long int address, BYTE data)
{
short int status;
i2c_start();
i2c_write(0xA0);
i2c_write(address>>8);
i2c_write(address);
i2c_write(data);
i2c_stop();
i2c_start();
status=i2c_write(0xA0);
while(status==1)
{
i2c_start();
status=i2c_write(0xA0);
}
i2c_stop();
}
BYTE read_ext_eeprom(long int address) {
BYTE data;
i2c_start();
i2c_write(0xA0);
i2c_write(address>>8);
i2c_write(address);
i2c_start();
i2c_write(0xA1);
data=i2c_read(0);
i2c_stop();
return(data);
}
Edit:
Bitte Code-Tags verwenden!
Stampede