View previous topic :: View next topic |
Author |
Message |
ekocakaya
Joined: 13 Aug 2006 Posts: 12
|
!!! Really Need Help (MAX7300 Problem) |
Posted: Wed Aug 16, 2006 2:20 am |
|
|
I am using 18F4620 PIC and MAX7300 ANI .I ground AD0 and AD1 pins of MAX7300 for adressing.and using ccs library MAX7300.C but I didnt communicate PIC and MAX yet.I need help for this.I use 4.7k resistors for SCL and SDA.anybody have program example? or what is max7300 adress where I will use this address
Please help me
Code: |
#include <18F4620.h>
#fuses NOWDT,INTRC_IO, NOPUT, NOMCLR, BROWNOUT, NOCPD, NOWRT, NODEBUG, NOPROTECT, FCMEN, IESO
#define OSC_4MHZ | OSC_INTRC
#use delay(clock=4000000)
#include <max7300.c>
void main()
{
int durum,i;
int a=0x0xA0;
high_count = high_start;
max7300_init(0xA0);
setup_oscillator( OSC_8MHZ);
setup_comparator(NC_NC_NC_NC);
do
{
for(i=0;i<255;i++)
{
durum=input_pin_ext(0xA0,12);
if(durum!=0){
OUTPUT_HIGH(PIN_B6);
delay_ms(1000);
OUTPUT_LOW(PIN_B6);
OUTPUT_HIGH(PIN_D5);
delay_ms(1000);
OUTPUT_LOW(PIN_D5);
delay_ms(1000);
OUTPUT_HIGH(PIN_D4);
delay_ms(1000);
OUTPUT_LOW(PIN_D4);
delay_ms(1000);
}
delay_ms(200);
}
OUTPUT_HIGH(PIN_B6);
delay_ms(1000);
OUTPUT_LOW(PIN_B6);
}while(true);
} |
Last edited by ekocakaya on Wed Aug 16, 2006 5:53 am; edited 7 times in total |
|
|
Ttelmah Guest
|
|
Posted: Wed Aug 16, 2006 4:17 am |
|
|
Turn off html, and use the 'code' buttons to post code. Otherwise it is unreadable.
You need to set MAX7300_CLK (and data), to suit the pins you are using, before including the driver file.
Set the processor oscillator up, before initialising the chip.
Presumably you mean 'AD0' and 'AD1'?. If these are grounded, the device address, is 0x80, not 'A0'.
Best Wishes |
|
|
ekocakaya
Joined: 13 Aug 2006 Posts: 12
|
|
Posted: Wed Aug 16, 2006 4:34 am |
|
|
what do you mean with need to set max7300_clk? I still trying but ı didnt system get work? what can I do? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Aug 16, 2006 6:32 am |
|
|
ekocakaya wrote: | what do you mean with need to set max7300_clk? I still trying but ı didnt system get work? what can I do? | Look into max7300.c, in the top of this file you see Code: | #ifndef MAX7300_CLK
#define MAX7300_CLK PIN_C3
#define MAX7300_DATA PIN_C4
#endif | This means that if you don't define the pins to be used for the clock and data lines, than the compiler will set PIN_C3 and PIN_C4 to be used as default.
Change your code to something like Code: | #define MAX7300_CLK PIN_something
#define MAX7300_DATA PIN_something
#include <max7300.c> |
Last edited by ckielstra on Wed Aug 16, 2006 6:45 am; edited 2 times in total |
|
|
ekocakaya
Joined: 13 Aug 2006 Posts: 12
|
|
Posted: Wed Aug 16, 2006 6:38 am |
|
|
I already did it.But still I dont know why it isnt working |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Aug 16, 2006 6:45 am |
|
|
Also add the NOLVP fuse to your #fuses line. About 99% of the people are using a high voltage programmer (ICD or similar device) to program the PIC. Otherwise with the LVP configuration bit active (default) you can't use pin B5 for I/O, and when you forget to connect B5 to ground normal program execution will not work reliable. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Aug 16, 2006 6:58 am |
|
|
Code: | #use delay(clock=4000000)
...
...
setup_oscillator( OSC_8MHZ); | Why are you changing the clock speed? Now the speed of the delay routines is incorrect. Set the required speed in the #use delay() line and the compiler will set up the correct processor speed in the startup code (you can remove the setup_oscillator call).
I see some lines in your program that are corrupted because of HTML being enabled by default. Add all suggested improvements to your program and then post it again making sure the 'Disable HTML' button is checked. |
|
|
|