软件开发PMC234+AT24C01程序源码
软件开发单片机源程序如下:
- #include "extern.h"
- /***********************************************************************************************/
- void at24cxx_Delay_5us( void );
- void at24cxx_Delay_10us( void );
- void at24cxx_Delay_10ms( void );
- void AT24CXX_IO_Init( void );
- void AT24CXX_CLK_LOW( void );
- void AT24CXX_CLK_HIGH( void );
- void AT24CXX_IO_LOW( void );
- void AT24CXX_IO_HIGH( void );
- void at24cxx_IO_input( void );
- void at24cxx_IO_ouput( void );
- void at24cxx_Start( void );
- void at24cxx_Stop( void );
- void at24cxx_SEND_ACK( void );
- void at24cxx_SEND_NACK( void );
- void at24cxx_RECV_ACK( void );
- void at24cxx_Recv_Char( void );
- void at24cxx_Send_Char( void );
- void read_Random_Byte( void );
- void write_Random_Byte( void );
- void read_eeprom_configuration( void );
- void write_eeprom_configuration( void );
- /***********************************************************************************************/
- void FPPA0 (void)
- {
- .ADJUST_IC SYSCLK=IHRC/2, IHRC=16MHz, VDD=5V, Bandgap=On;
- // Insert Initial Code
- AT24CXX_IO_Init();
- while (1)
- {
- // ...
- // wdreset;
- read_eeprom_configuration();
- write_eeprom_configuration();
- }
- }
- void FPPA1 (void)
- {
- goto $;
- }
- void Interrupt (void)
- {
- pushaf;
- if (Intrq.T16)
- { // T16 Trig
- // User can add code
- Intrq.T16 = 0;
- //...
- }
- popaf;
- }
- /******************************************************/
- /***********************************************************************************************
- * \brief This function is just used to generate some example data for write operations
- * on the card.
- *
- **********************************************************************************************/
- void at24cxx_Delay_5us( void )
- {
- .delay 100;
- }
- void at24cxx_Delay_10us( void )
- {
- .delay 200;
- }
- void at24cxx_Delay_10ms( void )
- {
- .delay 200;
- .delay 200;
- .delay 200;
- .delay 200;
- .delay 200;
- }
- /***********************************************************************************************/
- void AT24CXX_IO_Init( void )
- {
- //SCL
- PA.0 = 1;
- PAC.0 = 1;
- //SDA
- PA.5 = 1;
- PAC.5 = 0;
- }
- /***********************************************************************************************/
- void AT24CXX_CLK_LOW( void )
- {
- PA.0 = 0;
- }
- void AT24CXX_CLK_HIGH( void )
- {
- PA.0 = 1;
- }
- /***********************************************************************************************/
- void AT24CXX_IO_LOW( void )
- {
- PA.5 = 0;
- }
- void AT24CXX_IO_HIGH( void )
- {
- PA.5 = 1;
- }
- /***********************************************************************************************
- * \brief This function is just used to generate some example data for write operations
- * on the card.
- *
- **********************************************************************************************/
- void at24cxx_IO_input( void )
- {
- PAC.5 = 0;
- }
- void at24cxx_IO_ouput( void )
- {
- PAC.5 = 1;
- }

芯片解密