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

[SOLVED] internal oscillator with PIC18F45K80
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
vas57



Joined: 31 Jan 2022
Posts: 30

View user's profile Send private message

PostPosted: Sat Apr 11, 2026 12:54 pm     Reply with quote

Cine ma poate ajuta cu un sfat ?
Incerc sa scriu cu un modul PN532(NXP), intr-un mifare desfire ev1 o aplicatie cu programul de mai jos, dar nu orimesc confirmarea pentru realizarea ei. Este formatul comenzilor gresit? Programul imi trezeste cardul si imi scoate UID-ul lui.


[#include <18F46K22.h>
#fuses NOWDT, NOPROTECT, NOLVP, NOMCLR
#use delay(crystal=20000000)

// UART1 la 115200
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, stream=NFC_BUS, errors)

void main() {
unsigned int8 i, len;
unsigned int8 buffer[64];

// 1. Trezire (Wake-up)
unsigned int8 const WAKE[] = {0x55,0x55,0x00,0x00,0x00,0x00,0x00,0xFF,0x03,0xFD,0xD4,0x14,0x01,0x17,0x00};
// 2. AUTO-POLL (Inlocuieste SCAN si RATS) - DCS: B9
unsigned int8 const POLL[] = {0x00,0x00,0xFF,0x05,0xFB,0xD4,0x60,0x01,0x01,0x10,0xB9,0x00};
// 3. CREATE APP (40 01 CA) - DCS: 20
unsigned int8 const CREATE[] = {0x00,0x00,0xFF,0x09,0xF7,0xD4,0x40,0x01,0xCA,0x12,0x34,0x56,0x0F,0x01,0x20,0x00};

setup_adc_ports(NO_ANALOGS);
delay_ms(1000);

// TREZIRE INITIALA
for(i=0; i<15; i++) fputc(WAKE[i], NFC_BUS);
delay_ms(500);

while(TRUE) {
// Gole?te orice rest din Rx
while(kbhit(NFC_BUS)) fgetc(NFC_BUS);

// 1. SCANARE (Cea care a mers mereu) - DCS: E1
unsigned int8 const CMD_S[] = {0x00,0x00,0xFF,0x04,0xFC,0xD4,0x4A,0x01,0x00,0xE1,0x00};
for(i=0; i<11; i++) fputc(CMD_S[i], NFC_BUS);
delay_ms(200);

// 2. ACTIVARE DATE (RATS) - DCS: D5
// Trimitem fortat, imediat dupa scanare
unsigned int8 const CMD_R[] = {0x00,0x00,0xFF,0x03,0xFD,0xD4,0x56,0x01,0xD5,0x00};
for(i=0; i<10; i++) fputc(CMD_R[i], NFC_BUS);
delay_ms(200);

// 3. CREARE APLICATIE - DCS: 20
unsigned int8 const CMD_C[] = {0x00,0x00,0xFF,0x09,0xF7,0xD4,0x40,0x01,0xCA,0x12,0x34,0x56,0x0F,0x01,0x20,0x00};
for(i=0; i<16; i++) fputc(CMD_C[i], NFC_BUS);

delay_ms(1500);
}

}
][/code]
temtronic



Joined: 01 Jul 2010
Posts: 9635
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Apr 12, 2026 6:55 am     Reply with quote

seems to be Romanian....Google helped !

Who can help me with an advice?
I'm trying to write with a PN532(NXP) module, in a mifare desfire ev1 an application with the program below, but I can't get the confirmation for its execution. Is the command format wrong? The program wakes up my card and gives me its UID.
dyeatman



Joined: 06 Sep 2003
Posts: 1981
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Apr 12, 2026 7:28 am     Reply with quote

Several problems I have with this post:
1. Piggybacked on another thread from more than EIGHT years ago when they
should have started a new one
2. Posted in Romanian rather than English so most users here don't
know what he said starting out without a translator.
3. Looks like the program structure needs a fair amount of work. Lots
of delays and not using interrupts, etc.
_________________
Google and Forum Search are some of your best tools
Ttelmah



Joined: 11 Mar 2010
Posts: 20063

View user's profile Send private message

PostPosted: Sun Apr 12, 2026 9:25 am     Reply with quote

Also, the code itself is commented in English, which suggests he has
taken it from somewhere. We have no way of knowing that his hardware
is correct for this code. Has he got a 20MHz crystal?. Is the unit correctly
wired to the serial pins?. Is the chip even running?.
These all need to be tested and proven before trying to run this code.
temtronic



Joined: 01 Jul 2010
Posts: 9635
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Apr 12, 2026 12:02 pm     Reply with quote

and then there's the 5 volt PIC with 3 volt peripheral problem......

...I don't assume any 3 volt 'device' is truly 5 volt compatible.
dyeatman



Joined: 06 Sep 2003
Posts: 1981
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Apr 12, 2026 2:09 pm     Reply with quote

Quote:
And then there's the 5 volt PIC with 3 volt peripheral problem......


yeah...that too! Shocked
_________________
Google and Forum Search are some of your best tools
Ttelmah



Joined: 11 Mar 2010
Posts: 20063

View user's profile Send private message

PostPosted: Mon Apr 13, 2026 10:54 am     Reply with quote

temtronic wrote:
and then there's the 5 volt PIC with 3 volt peripheral problem......

...I don't assume any 3 volt 'device' is truly 5 volt compatible.


Good point. It would actually be that the 5v device (the PIC), will require
signals that go to about 4v on it's serial input, so without level translation,
it is not going to work.
Hardware details of where he got the code from, really are essential....

Looking at the chips, this is the most likely problem.
The communication device supports 5v operation, but has an internal LDO,
and the communication connections are designed for 3v operation.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
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