| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| kmp84 
 
 
 Joined: 02 Feb 2010
 Posts: 382
 
 
 
			    
 
 | 
			
				| EM4095 RFID |  
				|  Posted: Mon Dec 10, 2018 3:36 pm |   |  
				| 
 |  
				| Hello, 
 I have successfully run CCS's em4095 front-end driver with pic16F886 mcu.
 Is it possible to run em4095 with 16F1459 ? PIC16F1459 has not 2x CCP module.
 
 I'm using https://www.mikroe.com/rfid-reader-board board. There is sample example using #EXT_INT.  How to convert to CCS especially this part of code:
  	  | Code: |  	  | void Interrupt() {
 
 // This is external INT1 interrupt (for sync and sample)
 //     it is enabled until we get 128 data bits
 if (INT1IF_bit && INT1IE_bit) {
 cnt++;                  // count interrupts on INT1 pin (RB1)
 INT1IF_bit = 0;
 }
 
 // This is external INT0 interrupt (for sync start)
 //   - once we get falling edge on RB0 we are disabling INT0 interrupt
 else if (INT0IF_bit && INT0IE_bit) {
 cnt = 0;
 sync_flag = 1;
 INT0IF_bit = 0;
 INT0IE_bit = 0;
 INT1IF_bit = 0;
 INT1IE_bit = 1;
 }
 }
 
 | 
 
 Best Wishes!
 |  | 
	
		|  | 
	
		| temtronic 
 
 
 Joined: 01 Jul 2010
 Posts: 9588
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Dec 10, 2018 3:51 pm |   |  
				| 
 |  
				| OK, well the EASY way is to use the CCS supplied driver ! Just look in the 'drivers' folder. It's called 'EM4095.c'. OK, I just scanned the driver and it uses 2 CCPs as well...hmm...now I'm thinking you should choose another PIC.....
 seems they use 1 ISR to xmt, another to rcv.... now IF you only do 1 function ( xmt OR rcv) ,then 1 ccp should work for you.
 If there was a known time lag between xmt and rcv, yop might be able to reconfigure the CCP as required ??
 I've never used the '4095' chip, so hopefully others that have will reply soon.
 
 Jay
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Dec 11, 2018 12:29 am |   |  
				| 
 |  
				| The Microe example is using INT_EXT0 and INT_EXT1. Simply a counter in INT_EXT1, and a reset of this in INT_EXT0.
 
 Won't work on your chip, since it requires two external interrupts....
 Key line:
 
  	  | Quote: |  	  | The code demonstrates using two external interrupts to read data sent
 
 | 
 
 What they are doing is feeding the clock output from the chip into INT_EXT1
 then looking for a falling edge on INT_EXT0, resetting the counter and
 enabling INT_EXT1 with this.
 
 Honestly be aware that on the 16F1459, USB will use something like 1/3rd
 of the ROM just for bare operation. If you want a simple way to use
 USB, honestly 100* better to just use a simple USB-UART externally. These
 cost tiny amounts, and leave you with all the code space in your chip.
 
 The CCP driver will work with only one CCP.
 CCP2 is only used for transmission. Depends if your device needs
 transmission?....
 |  | 
	
		|  | 
	
		| kmp84 
 
 
 Joined: 02 Feb 2010
 Posts: 382
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Dec 11, 2018 3:50 am |   |  
				| 
 |  
				| Hi mr. temtronic, mr. Ttelmah! 
 External USB-UART chip is good idea, but some of my projects use "HID Device" and want to has flex device (CardReader)!
 
 Thanks!
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Dec 11, 2018 10:15 am |   |  
				| 
 |  
				| Well in which case get a larger USB chip that has the peripherals needed to do the EM4095 comms...
 |  | 
	
		|  | 
	
		| kmp84 
 
 
 Joined: 02 Feb 2010
 Posts: 382
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Dec 13, 2018 2:19 am |   |  
				| 
 |  
				| Thanks for all suggestion! I'm planning to use "PIC18F24K50" for this project. 
 Best Wishes!
 |  | 
	
		|  | 
	
		|  |