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

em4095 and PIC18fxxxx

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



Joined: 31 May 2007
Posts: 20

View user's profile Send private message

em4095 and PIC18fxxxx
PostPosted: Mon Jul 30, 2007 1:32 pm     Reply with quote

does anyone has worked with the em4095 and a pic18 series.
I worked with a pic 16 and works fine, but when I changed to the pic18 the code does not work. it does not decode the tag, or recognize it.

I've change in the em4095 drivers the line
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256);

for this one
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256 | RTCC_8_BIT);

but I still don't get anything.

If anyone has make the pic18 worked whith the em please a little help.

thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 1:53 pm     Reply with quote

Post your compiler version for the PCM and the PCH compilers.
lmercor



Joined: 31 May 2007
Posts: 20

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 1:58 pm     Reply with quote

I'm working with 4.013 version for PCM and PCH
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 2:08 pm     Reply with quote

Are you using the demo ? I know that 4.013d was a demo version.
If so, I'd advise that you download the latest demo. 4.013 is really
too early a version. There could easily be a bug in there that's causing
your current problem.
lmercor



Joined: 31 May 2007
Posts: 20

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 4:40 pm     Reply with quote

I compiled the program in another version, (a friend of mine has 4.033 version) and I still don't get anything. so I really can't imagine what could it be, because in the pic877 works perfect. and I did change the setup line for the timer.

any thought...

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 4:49 pm     Reply with quote

What 18F PIC are you using ?

Did you make any changes to the circuit ?
Are you using a different board for the 18F version ?

Have you run an LED blinking program, or something similar, just
to test that the 18F board works at all ?
lmercor



Joined: 31 May 2007
Posts: 20

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 5:08 pm     Reply with quote

I'm using the PIC18F4550 and also I've tried the PIC18F4455 and the same result with the two pics, I 've done a led program with the 18 pic and works fine.

I developed a rfid reader using the em4095 and using 2 pics a 16f877 connected directly to the em4095 and 18f4550 to send the data over usb, the 877 decode the data from the em4095 and send it to the 18f4550 and the 4550 send the data to the pc and the circuit works fine, the programs works perfect, but now I want to use just one pic, the 18. I did a led program and works on the 4550, I did a basic decode program for the em using the drivers and does not work, I tried the same program in the 877 and it works good. so I don¡t know why the program does not work on the 4550.

thanks for your replies.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 5:51 pm     Reply with quote

Quote:
I did a basic decode program for the em using the drivers and does not work


I can't trouble-shoot your program because I don't have access to it.
Using the CCS example, Ex_RFID.c, which calls the "em" drivers,
I can see one problem in it. This file is supposed to be compilable
for a 16F876A or an 18F452. But, the eeprom address is set at the
value for the 16F-series (0x2100). There's no #ifdef statement to put
in the proper address for the 18F-series when compiling with PCH.
This will make it fail for the 18F.
Code:

#define EEPROMBASE 0x2100         // base address of EEPROM

There might be other things in there like this.
lmercor



Joined: 31 May 2007
Posts: 20

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 6:21 pm     Reply with quote

here is my code. i'm not using the eeprom of the pic.
Code:
#include <18F4550.h>

#fuses XTPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL1,CPUDIV3,VREGEN
#fuses BROWNOUT, BORV28, NOCPD, STVREN, NOIESO, NOFCMEN, NOPBADEN, CCP2B3
#use delay(clock=48000000)

#include <em4095mio18f4550.c>
#include <em4102.c>
void main(void) {
   int8 code[5];
   int8 i, j, k;
   int8 dato_org;
   set_tris_d(0b00000000);
   delay_ms(10);
   output_d(0b00000111);

   rf_init();     //initialization
   rf_powerUp();

 while(TRUE)
 {
   if(read_4102(code))  //read the code
   {
      for (i=0; i<5; i++) {
         dato_org = code[i];
         code[i] = 0;
         for (j=0; j<8; j++) {
            code[i] |= ((dato_org>>(j)) & 0x01);
            if(j<=6) {
             code[i] <<= 1;
            }

         }
      }

for (k=0;k<5;k++){
output_d(k);
output_b(code[k]);
delay_ms(50);
}
   }
 }
}


the code above is the main program. some fuses are changed at the moment of programming the pic. I check if the program is working just putting some leds at portd and portb.

and here is the em driver with minor changes. just the line
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256 | RTCC_8_BIT);

Code:

#ifndef EM4095
#define EM4095

#ifndef RF_SHD
#define RF_RDY_CLK   PIN_C0         // External interrupt used to read clock
#define RF_SHD       PIN_A0         // High disables the antenna signal
#define RF_DEMOD_OUT PIN_C2         // Data read in interrupt service routine
#endif

// Provide a buffer for storing recieved data and data to be sent
#define RFBUFFER_SIZE 20
int8 RFbuffer[RFBUFFER_SIZE];
int8 RFbuffer_index = 0;
int8 RFbuffer_bitIndex = 0;
#define END_OF_RFBUFFER (RFbuffer_index == sizeof(RFbuffer))


/////////////////////////////////////////////////////////////////////////
//// Read modes available for reading data from a transponder
/////////////////////////////////////////////////////////////////////////
int8 RF_readMode;
#define RF_MANCHESTER_DATA    0     // Reads Manchester encoded data
#define RF_MEASURE_WIDTHS     1     // Measure a series of widths
#define RF_FIND_WIDTH         2     // Find a specific width
#define RF_FIND_PATTERN       3     // Find a pattern of widths
/////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////
//// Global Variables
/////////////////////////////////////////////////////////////////////////
int1  bitValue              = 1;
int1  storeData             = TRUE;
int1  RE_FE_TOGGLE          = 1;
int1  RF_widthFound         = FALSE;
int1  RF_patternFound       = FALSE;
int8  RF_widthToFind        = 0;
int8* RF_findWidths         = 0;
int8  RF_uncertainty        = 0;
int8  timer0_overflows      = 0;
int8  dataTransferred       = 0;
int16 old_clock             = 0;
/////////////////////////////////////////////////////////////////////////


// Purpose:       Initializes the 4095 into sleep mode
//                Sets up the timers and interrupts
void rf_init()
{
   output_low(RF_SHD);

   setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1);
   setup_ccp1(CCP_CAPTURE_RE);
   setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256 | RTCC_8_BIT);
   enable_interrupts(INT_RTCC);
   enable_interrupts(GLOBAL);
}

// Purpose:       Powers down the RF antenna
#define rf_powerDown()  output_high(RF_SHD);

// Purpose:       Powers up the RF antenna
#define rf_powerUp()    output_low(RF_SHD);




the rest of the code is the same as the one in the drivers folder.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 30, 2007 10:47 pm     Reply with quote

I think you're trying to change too much. In other words, when you're
porting code that was working at 20 MHz on a 16F PIC, you shouldn't
immediately boost the speed to 48 MHz on a 18F. Try it at 20 MHz first.
Change as little as possible, in all aspects. Try to use the same compiler
version as well.
ducbin



Joined: 04 Apr 2009
Posts: 3

View user's profile Send private message ICQ Number

To lmercor - Do you have code for PIC 16F877A.Please send me
PostPosted: Sun Apr 05, 2009 6:10 am     Reply with quote

To lmercor - Do you have code for PIC 16F877A.Please send me. I'm doing project about RFID. I'm making RFID reader using Pic16F877, chip EM4095, tag 4102. I wrote code but it doesn't work. Please post for me your code. Thank you very much !
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