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

9356 eeprom

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



Joined: 04 Jul 2010
Posts: 1

View user's profile Send private message

9356 eeprom
PostPosted: Sun Jul 04, 2010 4:19 pm     Reply with quote

Hi, I have difficulties to make modification to my project which use 16F877 to read and write to external eeprom 9356. It works when I use two pins to read and write. But I need to use two pins of Port B to read and write (short the pins 3 and 4 on the eeprom 9356).
My code is as follow:
Code:

#include <prototype.h>
#include <utility.c>

#include <9356.c>
#include <stdio.h>
#use rs232 ( baud=9600, xmit=PIN_C6, rcv=PIN_c7 )

/********************** main *************************/
void main ()
{   // start main
int count;
init_ext_eeprom();
count = read_ext_eeprom(0);

while ( TRUE )
  { // while ( TRUE )
   show_binary_on_leds ( count );
   wait_for_one_press ();
   count++;
   write_ext_eeprom ( 0, count );
   if (count >7)
     {
      count=0;
     }
  printf("count is %u\r\n", count);
  } // while ( TRUE )
} // End main

The code count BCD when press the push button, and should keep the last count if i disconnect the power and connect it back. It is doing that now, but when I short the two pins of the 9356 it is not functioning.

This is the Utility.c code
Code:

show_binary_on_leds(int n)
{
// show_binary_on_leds(int n)

output_high(green_led);
output_high(yellow_led);
output_high(red_led);

if(bit_test(n, 0))
    output_low(green_led);
if(bit_test(n, 1))
    output_low(yellow_led);
if(bit_test(n, 2))
    output_low (red_led);
}

// show_binary_on_leds(int n)

void wait_for_one_press()
{
while(input(push_button));
delay_ms(100); // Used to debounce PB
while(!input(push_button));
} // end wait for one press
 


This is the Prototype.h
Code:

#include <16f877A.h>
#device ICD=TRUE
#fuses HS, NOLVP, NOWDT, PUT
#use delay ( clock = 20000000 )

#define green_led PIN_A5 // The green led is connected to A5 (pin 8)
#define yellow_led PIN_B4 // The yellow led is connected to B4 (pin 41)
#define red_led PIN_B5 // The red led is connected to B5 (pin 42)
#define push_button PIN_A4 // Push button connected to A4 (pin 7)

#use rs232 (baud-9600, xmit=PIN_C6, rcv=PIN_C7) //Used for serial communication


This is to help you understand the whole code.

I appreciate your help
Thanks
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun Jul 04, 2010 5:43 pm     Reply with quote

Open the file "9356.c" (Drivers folder) and you will see the pins used to handle the 9356:
Code:

#define EEPROM_SELECT PIN_B4
#define EEPROM_CLK    PIN_B2
#define EEPROM_DI     PIN_B1
#define EEPROM_DO     PIN_B0


Re define them accordingly to your needs.

Humberto
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Jul 04, 2010 10:53 pm     Reply with quote

You have to modify the 9356 driver to use a common (bidirectional) data IO pin.
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