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 support@ccsinfo.com

i2c and 16f819 help

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



Joined: 20 Jun 2014
Posts: 14

View user's profile Send private message

i2c and 16f819 help
PostPosted: Mon Jul 28, 2014 9:40 am     Reply with quote

I need help with communication Pic 16f819 and rfid - sl030

Here is link for rfid SL030

http://www.sos.sk/a_info/resource/c/Stronglink/SL030.pdf

I don't see clock on scl and data on sda with scope.
I use pull up resistors on scl and sda to vcc.
In my code i want read UID of the Mifare card.
I don't know what's wrong.
I use internal oscillator.
Please help me.
Code:

#include <rfid.h>

unsigned int8 pocetcitani;

void main()

{

loop:
   {
   i2c_start();

i2c_write(0xa0);     // Device address sl030 for write

i2c_write(0x01);  // LEN leght

i2c_write(0x01);     // number of command

i2c_stop();

   }
   delay_ms(100);
   {
   i2c_start();

i2c_write(0xa1);     // Device address sl030 for read


 pocetcitani=i2c_read(0);   // read LEN
 
int i = 0;
unsigned int8 data[32];
 
For (i=0;i<pocetcitani;i++ )
{
data[i] = i2c_read();

}

i2c_stop();

   }   
 
}

Here are my fuses....:

Code:

#include <16F819.h>
#device ADC=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#device ICD=TRUE
#use delay(internal=8000000)
#use FIXED_IO( A_outputs=PIN_A7,PIN_A6,PIN_A5,PIN_A4,PIN_A3,PIN_A2,PIN_A1,PIN_A0 )
#use FIXED_IO( B_outputs=PIN_B7,PIN_B6,PIN_B5,PIN_B3,PIN_B2,PIN_B0 )
#use i2c(Master,Fast,sda=PIN_B1,scl=PIN_B4)


Last edited by peterzatko on Mon Jul 28, 2014 10:00 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Mon Jul 28, 2014 9:48 am     Reply with quote

Er. You say 'I use internal oscillator'.
However your code says 'use an external crystal'.

Look in the manual at the meaning of the keyword 'crystal', and the keyword 'internal', in the clock line.....

There are other problems (look at when you should NACK a read. Is this when you are doing it?).

However do the key thing. Start with a flash an LED test, and get the fuses/clock right, so the PIC is running.
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