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

EM4095 library can not run with PIC18F???

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



Joined: 16 Feb 2006
Posts: 9
Location: Viet Nam

View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger

EM4095 library can not run with PIC18F???
PostPosted: Thu Jul 16, 2009 1:50 am     Reply with quote

Hi all,
First, I want to say thank you to CCS Inc. There library help me so much in my RFID project. With the example, I can quickly successful design 125KHz reader based on em4095 and pic16f876a. now reader can work well with many PIC16F devices (16f877, 16f886, 16f887, 16f88...). I run at 20MHz crystal.

Now I'm try to upgrade my design to use PIC18F devices, here I used PIC18F2620 and PIC18F2550. I thought I will be fine and no problem. It just need a little bit change on include file, fuse settings, system clock that suitable with PIC18F devices.
My test board used 20MHz crystal and I set to HS mode.

But my thought was wrong Sad Reader can not read any 125KHz Read-Only tag I had. Shocked Shocked Shocked I try to find some issue in my code but it quite difficult, because I used same em4095 library that I did with PIC16F. I go to CCS forum to find some solution, some discussion about this and I found some others member had same issue like me, but the final solution to solve this still don't have.

http://www.ccsinfo.com/forum/search.php?mode=results

CCS supporter, could you have us solve this.

I think we need to focus on em4095 library when it run with PIC18F. Don't ask me some question like what is your fuse setting...etc because I sure my program run at correct system clock. Main issue here maybe related to Timer1 and CCP1 module.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 16, 2009 12:58 pm     Reply with quote

1. Post your compiler version (Always do this).

2. Post if this is being testing in hardware or a simulator (Always post this).

3. Post the exact 18F PIC that you are using for this test.
(Don't list two of them).

4. Post the list of pin numbers that you are using for these signals
in the EM4095 driver. The driver has these default values:
Code:

#define RF_RDY_CLK   PIN_C0  // External interrupt used to read clock
#define RF_SHD       PIN_B1  // High disables the antenna signal
#define RF_MOD       PIN_B2 // High does 100% modulation
#define RF_DEMOD_OUT PIN_C2 // Data read in interrupt service routine


5. Post your #fuses and #use delay() statements
Rogier



Joined: 25 Feb 2012
Posts: 12
Location: NL

View user's profile Send private message

PostPosted: Thu May 08, 2014 2:45 am     Reply with quote

I have the same problem. I have used the EM4095 application on many PIC16F devices. Usually on 16Mhz internal RC. Works great.

Now I ported this to a PIC18F14K50 without success.
Used 16Mhz, 48Mhz (with timing adaptions)
I use the read-only mode: MOD tied to ground, no use of CCP2.
I use CCS V4.140 (and tried also other older version without success)
I don't use the eeprom, I know about different eeprom base addresses.
I also tried fast_io and using tris_x (which I prefer normally). I know the difference between port_x, latch_x.


Here's some code of definitions.
Code:

#define RF_SHD          PIN_C2     
#define RF_RDY_CLK      PIN_C6      // T13CKI , used on TMR1
#define RF_DEMOD_OUT    PIN_C5      // compare/capture CCP1 


Here some settings:
Code:

SETUP_TIMER_3(T3_DISABLED);      
setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1);   // PIN_RC6 RDY_CLK,
setup_ccp1(CCP_CAPTURE_RE);            // PIN_C5 CCP1 demod out.
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256 | RTCC_8_BIT); //16,384 ms @ 16Mhz  5.46133 ms@48Mhz
enable_interrupts(INT_TIMER0);                         


This is the same code as I used earlier in pic16F versions. Even if I run the processor on 16Mhz, (INTRC no PLL) it doesn't work.

When using 'read_4102(code)' without a RFID tag it returns with FALSE of course, but If I take a RFID tag if will return with FALSE also. I can see that the time that is used in this function is shorter, so something is happening. Hardware design is the same as always, should work.

I understand that the example code should work on a PIC18F452. I never tried that. I'm now checking the datasheets for some differences between PIC18F452 and PIC18F14K50 (PWM/CCP/COM)/TMR etc)

Has anyone used the code on a PIC18F?
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Thu May 08, 2014 9:12 am     Reply with quote

The classic difference with any chip, is look for what peripherals are on the pins you are using, and make sure you turn off the ones you don't use.

On the original poster for this thread, they were using portB, and on the PIC18, this wakes up set for analog I/O.

So you need to look at the data sheet, and make sure you turn everything off that you are not using on the port pins.

Older chips had far less peripherals, so less of a problem....
Rogier



Joined: 25 Feb 2012
Posts: 12
Location: NL

View user's profile Send private message

PostPosted: Thu May 08, 2014 3:25 pm     Reply with quote

Thanks for your reply. As far as I know the used pins of PIC18F14k50 connected to EM4095 has the following functions:

DEMOD_OUT = RC5/CCP1/P1A/T0CKI
I used this in software:
Code:

SET_TRIS_c(0b01110010);   // make RC5 input
setup_ccp1(CCP_CAPTURE_RE);   // capture mode CCP1 pin
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256 | RTCC_8_BIT);


And for RDY_CLK = RC6/AN8/SS/T13CKI/T1OSC1
I used this:
Code:

SET_TRIS_c(0b01110010);   // make RC6 input
SETUP_ADC_PORTS(NO_ANALOGS);
SETUP_TIMER_3(T3_DISABLED);  // then T13CKI at least for TMR1
setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1);   


So this should be ok (not sure about SS and T1OSC1). But, I was wondering while writing this post if the timer1 setup was correctly done by the compiler, so I changed it manually:

Code:

#word T1CON   =   0xFCD
T1CON = 0b10000011;  // timer1 16 bits, external clock T13CKI, enable timer1   


.. I don't know which bit did the trick, but now it works anyway!

Thank you for pointing me out!
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