1331 views|0 replies

2015

Posts

0

Resources
The OP
 

msp430 MCU rc522 radio frequency program and circuit diagram [Copy link]

The microcontroller source program is as follows:

  1. #include<msp430x41x.h>
  2. #include "main.h"
  3. #include "mfrc522.h"
  4. #pragma memory = constseg(TAB)
  5. unsigned char data1[16] = {0x12,0x34,0x56,0x78,0xED,0xCB,0xA9,0x87,0x12,0x34,0x56,0x78,0x01,0xFE,0x01,0xFE};
  6. //If a block of the M1 card is written in the following format, then this block is a wallet and can receive deduction and recharge commands
  7. //4-byte amount (low byte first) + 4-byte amount inverted + 4-byte amount + 1-byte block address + 1-byte block address inverted + 1-byte block address + 1-byte block address inverted
  8. unsigned char data2[4]= {0x12,0,0,0};
  9. unsigned char DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  10. #pragma memory=default
  11. unsigned char g_ucTempbuf[20];
  12. void main(void)
  13. {
  14. unsigned char status;
  15. InitializeSystem();
  16. PcdReset();
  17. PcdAntennaOff();
  18. PcdAntennaOn();
  19. while ( 1 )
  20. {
  21. status = PcdRequest(PICC_REQALL, g_ucTempbuf);
  22. if (status != MI_OK)
  23. {
  24. LED_GREEN_OFF;
  25. continue;
  26. }
  27. LED_GREEN_ON; // detect the presence of card
  28. status = PcdAnticoll(g_ucTempbuf);
  29. if (status != MI_OK)
  30. { continue; }
  31. status = PcdSelect(g_ucTempbuf);
  32. if (status != MI_OK)
  33. { continue; }
  34. status = PcdAuthState(PICC_AUTHENT1A, 1, DefaultKey, g_ucTempbuf);
  35. if (status != MI_OK)
  36. { continue; }
  37. status = PcdWrite(1, data1);
  38. if (status != MI_OK)
  39. { continue; }
  40. status = PcdValue(PICC_DECREMENT,1,data2);
  41. if (status != MI_OK)
  42. { continue; }
  43. status = PcdBakValue(1, 2);
  44. if (status != MI_OK)
  45. { continue; }
  46. status = PcdRead(2, g_ucTempbuf);
  47. if (status != MI_OK)
  48. { continue; }
  49. PcdHalt();
  50. }
  51. }
  52. /////////////////////////////////////////////////////////////////////
  53. //Function: system initialization
  54. /////////////////////////////////////////////////////////////////////
  55. void InitializeSystem(void)
  56. {
  57. WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer
  58. _DINT();
  59. P1DIR = 0xE8;
  60. P1OUT = 0xFF;
  61. P6DIR = 0x08;
  62. P6OUT = 0xFF;
  63. }
This post is from Microcontroller MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list