打印
[技术问答]

N76E003例程例怎么没有SPI的?

[复制链接]
4136|15
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
gwl518|  楼主 | 2017-2-17 15:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
N76E003例程例怎么没有SPI的?求个SPI的例程。
评论
781354052 2020-3-12 09:47 回复TA
下载最新BSP开发包即可! 
沙发
huaxianjie| | 2017-2-17 16:27 | 只看该作者
本帖最后由 huaxianjie 于 2017-2-17 17:06 编辑

参考N76E885例程

使用特权

评论回复
板凳
wahahaheihei| | 2017-2-17 20:09 | 只看该作者
N76E885_SampleCode_Keil_C51_V1.0.0
这个咋样?

使用特权

评论回复
地板
wahahaheihei| | 2017-2-17 20:09 | 只看该作者
/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2015 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

//***********************************************************************************************************
//  Nuvoton Technoledge Corp.
//  Website: http://www.nuvoton.com
//  E-Mail : MicroC-8bit@nuvoton.com
//  Date   : Apr/21/2015
//***********************************************************************************************************

//***********************************************************************************************************
//  File Function: N76E885 SPI in Master mode demo code
//***********************************************************************************************************

#include <stdio.h>
#include "N76E885.h"
#include "Version.h"
#include "Typedef.h"
#include "Define.h"
#include "SFR_Macro.h"
#include "Common.h"
#include "Delay.h"

//***********************************************************************************************************
//  Application: SPI Function
//  Master send 0x90 and recevie 0x4E
//  Master send 0x01 and recevie 0x55
//  Master send 0x02 and recevie 0x56
//  Master send 0x03 and recevie 0x4F
//  Master send 0x04 and recevie 0x54
//
//  Master recevie 0x4E and 0x4F form slave after transmitting
//***********************************************************************************************************

//------------------------- <<< Use Configuration Wizard in Context Menu >>> --------------------------------
////<e0> System Clock Source Configuration
// <o1> System Clock Source Selection
//      <0=> 2~25MHz    XTAL
//      <1=> 32.768KHz  XTAL
//      <2=> 22.1184MHz Internal
//      <3=> 10KHz      Internal
//      <4=> OSC-In     External
//</e>
//
//<e2> Clock Divider Configuration
//     <o3.0..7>  System Clock Source Devider <1-255>
//                     <i> Fsys = (System Clock Source) / (2 * Devider)
//</e>
//
// <o4> SPI Clock Divider Selection
//      <0=> Fsys/4
//      <1=> Fsys/8
//      <2=> Fsys/16
//      <3=> Fsys/32
//
//-------------------------------- <<< end of configuration section >>> -------------------------------------

#define SYS_CLK_EN              0
#define SYS_SEL                 2
#define SYS_DIV_EN              0               //0: Fsys=Fosc, 1: Fsys = Fosc/(2*CKDIV)
#define SYS_DIV                 1
#define SPI_DIV                 1
bit BIT_TMP;
//-----------------------------------------------------------------------------------------------------------
void SPI_Error(void)
{
    printf ("\nSPI error.\n");
    while(1)                                    // SPI error and P0.7 flash/
    {
        P07 = 1;
        Timer0_Delay1ms(500);
        P07 = 0;
        Timer0_Delay1ms(500);
    }
}
//-----------------------------------------------------------------------------------------------------------
void SPI_Clock_Select(void)
{
    #if   SPI_DIV == 0
            clr_SPR0;                           // SPI clock = Fosc/4
            clr_SPR1;
    #elif SPI_DIV == 1
            set_SPR0;                           // SPI clock = Fosc/8
            clr_SPR1;
    #elif SPI_DIV == 2
            clr_SPR0;                           // SPI clock = Fosc/16
            set_SPR1;
    #elif SPI_DIV == 3
            set_SPR0;                           // SPI clock = Fosc/32
            set_SPR1;
    #endif
}
//-----------------------------------------------------------------------------------------------------------
void SPI_Initial(void)
{      
    clr_P0M1_4;                                 //P04 (SS) Quasi mode
    clr_P0M2_4;
   
    clr_P0M1_5;                                 //P05 (SPCLK) Quasi mode
    clr_P0M2_5;
   
    clr_P2M1_1;                                 //P21 (MOSI) Quasi mode
    clr_P2M2_1;
   
    clr_P2M1_2;                                 //P22 (MISO) Quasi mode
    clr_P2M2_2;
   
    set_DISMODF;                                // SS General purpose I/O ( No Mode Fault )
    clr_SSOE;
   
    clr_LSBFE;                                  // MSB first         

    clr_CPOL;                                   // The SPI clock is low in idle mode
    set_CPHA;                                   // The data is sample on the second edge of SPI clock
   
    set_MSTR;                                   // SPI in Master mode
    SPI_Clock_Select();                         // Select SPI clock
    set_SPIEN;                                  // Enable SPI function
    clr_SPIF;
}
//-----------------------------------------------------------------------------------------------------------
void Start_Sending_SPI(UINT8 *pu8MID,UINT8 *pu8DID)
{
    SS = 0;
      
    SPDR = 0x90;
    Delay10us(1);                               // Send 0x90 to Slave
    while(!(SPSR & SET_BIT7));
    clr_SPIF;
    if(SPDR != 0x4E)
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);
   
    SPDR = 0x01;                                // Send 0x01 to Slave
    Delay10us(1);
    while(!(SPSR & SET_BIT7));
    clr_SPIF;
    if(SPDR != 0x55)
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);
   
    SPDR = 0x02;                                // Send 0x02 to Slave
    Delay10us(1);
    while(!(SPSR & SET_BIT7));   
    clr_SPIF;
    if(SPDR != 0x56)
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);

    SPDR = 0x03;                                // Send 0x03 to Slave
    Delay10us(1);
    while(!(SPSR & SET_BIT7));
    clr_SPIF;
    if(SPDR != 0x4F)
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);

    SPDR = 0x04;                                // Send 0x04 to Slave
    Delay10us(1);
    while(!(SPSR & SET_BIT7));
    clr_SPIF;
    if(SPDR != 0x54)
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);

    SPDR = 0xFF;                  
    Delay10us(1);
    while(!(SPSR & SET_BIT7));
    clr_SPIF;
    *pu8MID = SPDR;                             // Receive Slave 1st DATA from Slave
    printf ("\nSlave Return %c!\n",SPDR);
        
    SPDR = 0xFF;                  
    Delay10us(1);
    while(!(SPSR & SET_BIT7));  
    clr_SPIF;           
    *pu8DID = SPDR;                             // Receive Slave 2nd DATA from Slave
    printf ("\nSlave Return %c!\n",SPDR);
        
    SS = 1;   
}
//-----------------------------------------------------------------------------------------------------------
void main(void)
{      
    UINT8 u8MID,u8DID;

    /* Note
       MCU power on system clock is HIRC (22.1184MHz), so Fsys = 22.1184MHz
    */
   
    Set_All_GPIO_Quasi_Mode();
    InitialUART0_Timer1_Type1(9600);             /* 9600 Baud Rate*/

    Show_FW_Version_Number_To_PC();
   
    printf ("\n*===================================================================");
    printf ("\n*  Name: N76E885 SPI Master(Polling) Demo Code.");
    printf ("\n*===================================================================\n");
        
    /* Change system closk source */
    #if SYS_CLK_EN == 1
        #if   SYS_SEL == 0
            System_Clock_Select(E_HXTEN);   //Fosc = 2~25MHz XTAL
        #elif SYS_SEL == 1
            System_Clock_Select(E_LXTEN);   //Fosc = 32.768KHz XTAL
        #elif SYS_SEL == 2
            System_Clock_Select(E_HIRCEN);  //Fosc = 22.1184MHz Internal RC
        #elif SYS_SEL == 3
            System_Clock_Select(E_LIRCEN);  //Fosc = 10KHz Internal RC
        #elif SYS_SEL == 4
            System_Clock_Select(E_OSCEN);   //Fosc = OSC-In External OSC
        #endif
    #endif
   
    #if SYS_DIV_EN == 1
        CKDIV = SYS_DIV;                        //Fsys = Fosc / (2* CLKDIV) = Fcpu
    #endif

                SPI_Initial();

                Start_Sending_SPI(&u8MID,&u8DID);
        
    if((u8MID != 0x4F)&&(u8DID != 0x4E))
        SPI_Error();

    printf ("\nSPI Test OK!\n");
    while(1);                                    // SPI transmission finish and P0.6 flash
}
//-----------------------------------------------------------------------------------------------------------

使用特权

评论回复
5
wahahaheihei| | 2017-2-17 20:10 | 只看该作者
/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2015 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

//***********************************************************************************************************
//  Nuvoton Technoledge Corp.
//  Website: http://www.nuvoton.com
//  E-Mail : MicroC-8bit@nuvoton.com
//  Date   : Apr/21/2015
//***********************************************************************************************************

//***********************************************************************************************************
//  File Function: N76E885 SPI in Salave mode demo code
//***********************************************************************************************************

#include <stdio.h>
#include "N76E885.h"
#include "Version.h"
#include "Typedef.h"
#include "Define.h"
#include "SFR_Macro.h"
#include "Common.h"
#include "Delay.h"

//***********************************************************************************************************
//  Application: SPI Function
//  Slave receive 0x90 and return 0x4E
//  Slave receive 0x01 and return 0x55
//  Slave receive 0x02 and return 0x56
//  Slave receive 0x03 and return 0x4F
//  Slave receive 0x04 and return 0x54
//
//  Slave send 0x4F and 0x4E to Master after receiving
//  
//  Output : P1.4 & P2.1 flash when SPI pass.
//           P0.7 flash when SPI error
//***********************************************************************************************************

/*
//-------- <<< Use Configuration Wizard in Context Menu >>> ------------
//
////<e0> System Clock Source Configuration
// <o1> System Clock Source Selection
//      <0=> 2~25MHz    XTAL
//      <1=> 32.768KHz  XTAL
//      <2=> 22.1184MHz Internal
//      <3=> 10KHz      Internal
//      <4=> OSC-In     External
//</e>
//
//<e2> Clock Divider Configuration
//     <o3.0..7>  System Clock Source Devider <1-255>
//                     <i> Fsys = (System Clock Source) / (2 * Devider)
//</e>
//
//-------- <<< end of configuration section >>> ------------------------------
*/

#define SYS_CLK_EN              0
#define SYS_SEL                 2
#define SYS_DIV_EN              0                   //0: Fsys=Fosc, 1: Fsys = Fosc/(2*CKDIV)
#define SYS_DIV                 1
bit BIT_TMP;
//-----------------------------------------------------------------------------------------------------------
void SPI_Error(void)
{
    while(1)                                    // SPI error and P0.7 flash/
    {
        P07 = 1;
        Timer0_Delay1ms(500);
        P07 = 0;
        Timer0_Delay1ms(500);
    }
}
//-----------------------------------------------------------------------------------------------------------
void SPI_Initial(void)
{
    clr_P0M1_4;                                 //P04 (SS) Quasi mode
    clr_P0M2_4;
   
    clr_P0M1_5;                                 //P05 (SPCLK) Quasi mode
    clr_P0M2_5;
   
    clr_P2M1_1;                                 //P21 (MOSI) Quasi mode
    clr_P2M2_1;
   
    clr_P2M1_2;                                 //P22 (MISO) Quasi mode
    clr_P2M2_2;
   
    set_P0S_5;                                  //Schmitt triggered input select.
   
    clr_MSTR;                                   // SPI in Slave mode
    clr_LSBFE;                                  // MSB first

    clr_CPOL;                                   // The SPI clock is low in idle mode
    set_CPHA;                                   // The data is sample on the second edge of SPI clock     
      
    set_SPIEN;                                  // Enable SPI function
    clr_SPIF;
}
//-----------------------------------------------------------------------------------------------------------
void Slave_Receive_Data(void)
{
    SPDR = 0x4E;                                // Receive Master 1st DATA
    while(!(SPSR & SET_BIT7));         
    clr_SPIF;
    if(SPDR != 0x90)                     
       SPI_Error();
                                                
    SPDR = 0x55;                                // Receive Master 2nd DATA
    while(!(SPSR & SET_BIT7));         
    clr_SPIF;
    if(SPDR != 0x01)
       SPI_Error();
                                                
    SPDR = 0x56;                                // Receive Master 3rd DATA
    while(!(SPSR & SET_BIT7));                  
    clr_SPIF;
    if(SPDR != 0x02)
        SPI_Error();
   
    SPDR = 0x4F;                                // Receive Master 4th DATA
    while(!(SPSR & SET_BIT7));                  
    clr_SPIF;
    if(SPDR != 0x03)
        SPI_Error();
                                                
    SPDR = 0x54;                                // Receive Master 5th DATA
    while(!(SPSR & SET_BIT7));                  
    clr_SPIF;
    if(SPDR != 0x04)
        SPI_Error();
}
//-----------------------------------------------------------------------------------------------------------
void Slave_tranmit_Data(void)
{
    SPDR = 0x4F;                                // Send 1st data (0x4F) to Master
    while(!(SPSR & SET_BIT7));      
    clr_SPIF;
    if(SPDR != 0xFF)
        SPI_Error();
   
    SPDR = 0x4E;                                // Send 2nd data (0x4E) to Master
    while(!(SPSR & SET_BIT7));      
    clr_SPIF;
    if(SPDR != 0xFF)
        SPI_Error();
}
//-----------------------------------------------------------------------------------------------------------
void main(void)
{   
    /* Note
       MCU power on system clock is HIRC (22.1184MHz), so Fsys = 22.1184MHz
    */
   
    Set_All_GPIO_Quasi_Mode();
    InitialUART0_Timer1_Type1(9600);             /* 9600 Baud Rate*/

    Show_FW_Version_Number_To_PC();
   
    printf ("\n*===================================================================");
    printf ("\n*  Name: N76E885 SPI Slave(Polling) Demo Code.");
    printf ("\n*===================================================================");  
        
    /* Change system closk source */
    #if SYS_CLK_EN == 1
        #if   SYS_SEL == 0
            System_Clock_Select(E_HXTEN);   //Fosc = 2~25MHz XTAL
        #elif SYS_SEL == 1
            System_Clock_Select(E_LXTEN);   //Fosc = 32.768KHz XTAL
        #elif SYS_SEL == 2
            System_Clock_Select(E_HIRCEN);  //Fosc = 22.1184MHz Internal RC
        #elif SYS_SEL == 3
            System_Clock_Select(E_LIRCEN);  //Fosc = 10KHz Internal RC
        #elif SYS_SEL == 4
            System_Clock_Select(E_OSCEN);   //Fosc = OSC-In External OSC
        #endif
    #endif
   
    #if SYS_DIV_EN == 1
        CKDIV = SYS_DIV;                        //Fsys = Fosc / (2* CLKDIV) = Fcpu
    #endif

    SPI_Initial();

    printf ("\nSPI Start Receive...\n");   
         
    Slave_Receive_Data();                       // Slave receive data from master
    Slave_tranmit_Data();                       // Slave transmit data to master
    while(1)                                    
    {
        P21 = 1;
        Timer0_Delay1ms(500);
        P21 = 0;
        Timer0_Delay1ms(500);
    }
}
//-----------------------------------------------------------------------------------------------------------

使用特权

评论回复
6
wahahaheihei| | 2017-2-17 20:11 | 只看该作者
/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2015 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

//***********************************************************************************************************
//  Nuvoton Technoledge Corp.
//  Website: http://www.nuvoton.com
//  E-Mail : MicroC-8bit@nuvoton.com
//  Date   : Apr/21/2015
//***********************************************************************************************************

//***********************************************************************************************************
//  File Function: N76E885 SPI in Master mode demo code
//***********************************************************************************************************

#include <stdio.h>
#include "N76E885.h"
#include "Version.h"
#include "Typedef.h"
#include "Define.h"
#include "SFR_Macro.h"
#include "Common.h"
#include "Delay.h"

//***********************************************************************************************************
//  Application: SPI Function
//  Master send 0x90 and recevie 0x4E
//  Master send 0x01 and recevie 0x55
//  Master send 0x02 and recevie 0x56
//  Master send 0x03 and recevie 0x4F
//  Master send 0x04 and recevie 0x54
//
//  Master recevie 0x4E and 0x4F form slave after transmitting
//
//  Output : P1.4 & P2.1 flash when SPI pass
//           UART show result on hyper-terminal
//           P0.7 flash when SPI error
//***********************************************************************************************************

/*
//-------- <<< Use Configuration Wizard in Context Menu >>> ------------
//
////<e0> System Clock Source Configuration
// <o1> System Clock Source Selection
//      <0=> 2~25MHz    XTAL
//      <1=> 32.768KHz  XTAL
//      <2=> 22.1184MHz Internal
//      <3=> 10KHz      Internal
//      <4=> OSC-In     External
//</e>
//
//<e2> Clock Divider Configuration
//     <o3.0..7>  System Clock Source Devider <1-255>
//                     <i> Fsys = (System Clock Source) / (2 * Devider)
//</e>
//
//-------- <<< end of configuration section >>> ------------------------------
*/

#define SYS_CLK_EN              0
#define SYS_SEL                 2
#define SYS_DIV_EN              0                   //0: Fsys=Fosc, 1: Fsys = Fosc/(2*CKDIV)
#define SYS_DIV                 1
#define SPI_DIV                 0
bit BIT_TMP;
//-----------------------------------------------------------------------------------------------------------
void SPI_Error(void)
{
    printf ("\nSPI error.\n");
    while(1)                                    // SPI error and P0.7 flash/
    {
        P07 = 1;
        Timer0_Delay1ms(500);
        P07 = 0;
        Timer0_Delay1ms(500);
    }
}
//-----------------------------------------------------------------------------------------------------------
void Enable_SPI_Interrupt(void)
{
    set_ESPI;                                   // Enable SPI interrupt
    set_EA;
}
//-----------------------------------------------------------------------------------------------------------
void SPI_Clock_Select(void)
{
    #if   SPI_DIV == 0
            clr_SPR0;                           // SPI clock = Fosc/4
            clr_SPR1;
    #elif SPI_DIV == 1
            set_SPR0;                           // SPI clock = Fosc/8
            clr_SPR1;
    #elif SPI_DIV == 2
            clr_SPR0;                           // SPI clock = Fosc/16
            set_SPR1;
    #elif SPI_DIV == 3
            set_SPR0;                           // SPI clock = Fosc/32
            set_SPR1;
    #endif
}
//-----------------------------------------------------------------------------------------------------------
void SPI_Initial(void)
{              
    clr_P0M1_4;                                 //P04 (SS) Quasi mode
    clr_P0M2_4;
   
    clr_P0M1_5;                                 //P05 (SPCLK) Quasi mode
    clr_P0M2_5;
   
    clr_P2M1_1;                                 //P21 (MOSI) Quasi mode
    clr_P2M2_1;
   
    clr_P2M1_2;                                 //P22 (MISO) Quasi mode
    clr_P2M2_2;
            
    set_DISMODF;                                // SS General purpose I/O ( No Mode Fault )
    clr_SSOE;
   
    clr_LSBFE;                                  // MSB first         

    clr_CPOL;                                   // The SPI clock is low in idle mode
    set_CPHA;                                   // The data is sample on the second edge of SPI clock
   
    set_MSTR;                                   // SPI in Master mode
     
    SPI_Clock_Select();                         // Select SPI clock
    Enable_SPI_Interrupt();                     // Enable SPI interrupt
    set_SPIEN;                                  // Enable SPI function
}
//-----------------------------------------------------------------------------------------------------------
void Start_Sending_SPI(UINT8 *pu8MID,UINT8 *pu8DID)
{
    SS = 0;

    SPDR = 0x90;                                // Send 0x90 to Slave
    PCON |= SET_BIT0;                           // Enter idle mode
    if(SPDR != 0x4E)                            // Receive slave 1st DATA
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);
                                          
    SPDR = 0x01;                                // Send 0x01 to Slave
    PCON |= SET_BIT0;                           // Enter idle mode
    if(SPDR != 0x55)                            // Receive slave 2nd DATA  
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);

    SPDR = 0x02;                                // Send 0x02 to Slave
    PCON |= SET_BIT0;                           // Enter idle mode
    if(SPDR != 0x56)                            // Receive slave 3rd DATA
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);

    SPDR = 0x03;                                // Send 0x03 to Slave
    PCON |= SET_BIT0;                           // Enter idle mode
    if(SPDR != 0x4F)                            // Receive slave 4th DATA
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);

    SPDR = 0x04;                                // Send 0x04 to Slave
    PCON |= SET_BIT0;                           // Enter idle mode
    if(SPDR != 0x54)                            // Receive slave 5th DATA
       SPI_Error();
    printf ("\nSlave Return %c!\n",SPDR);

    SPDR = 0x4F;                  
    PCON |= SET_BIT0;                           // Enter idle mode
    *pu8MID = SPDR;                             // Receive Slave 1st DATA fron Slave      
    printf ("\nSlave Return %c!\n",SPDR);

    SPDR = 0x4E;                  
    PCON |= SET_BIT0;                           // Enter idle mode            
    *pu8DID = SPDR;                             // Receive Slave 2nd DATA from Slave
    printf ("\nSlave Return %c!\n",SPDR);

    SS = 1;   
}
//-----------------------------------------------------------------------------------------------------------
void main(void)
{      
    UINT8 u8MID,u8DID;
   
    /* Note
       MCU power on system clock is HIRC (22.1184MHz), so Fsys = 22.1184MHz
    */
   
    Set_All_GPIO_Quasi_Mode();
    InitialUART0_Timer1_Type1(9600);             /* 9600 Baud Rate*/

    Show_FW_Version_Number_To_PC();

    printf ("\n*===================================================================");
    printf ("\n*  Name: N76E885 SPI Master(Interrupt) Demo Code.");
    printf ("\n*===================================================================");  
        
    /* Change system closk source */
    #if SYS_CLK_EN == 1
        #if   SYS_SEL == 0
            System_Clock_Select(E_HXTEN);   //Fosc = 2~25MHz XTAL
        #elif SYS_SEL == 1
            System_Clock_Select(E_LXTEN);   //Fosc = 32.768KHz XTAL
        #elif SYS_SEL == 2
            System_Clock_Select(E_HIRCEN);  //Fosc = 22.1184MHz Internal RC
        #elif SYS_SEL == 3
            System_Clock_Select(E_LIRCEN);  //Fosc = 10KHz Internal RC
        #elif SYS_SEL == 4
            System_Clock_Select(E_OSCEN);   //Fosc = OSC-In External OSC
        #endif
    #endif
   
    #if SYS_DIV_EN == 1
        CKDIV = SYS_DIV;                        //Fsys = Fosc / (2* CLKDIV) = Fcpu
    #endif
   
    SPI_Initial();

    printf ("\nSPI Start Transmit...\n");

    Start_Sending_SPI(&u8MID,&u8DID);
        
    if((u8MID != 0x4F)&&(u8DID != 0x4E))
        SPI_Error();

    printf ("\nSPI Test OK!\n");
    while(1)                                    // SPI transmission finish
    {
        P02 = 1;
        Timer0_Delay1ms(500);
        P02 = 0;
        Timer0_Delay1ms(500);
    }
}
//-----------------------------------------------------------------------------------------------------------
void SPI_ISR(void) interrupt 9                  // Vecotr [url=home.php?mod=space&uid=72445]@[/url]  0x4B
{
    clr_SPIF;
    Delay10us(1);
}
//-----------------------------------------------------------------------------------------------------------

使用特权

评论回复
7
yiyigirl2014| | 2017-2-17 20:46 | 只看该作者
N76E003的头文件是哪个?直接找跟他同一个头文件的例程就可以了,如果没有,那就是标准的C51单片机,直接用51的知识来搞就行了。

使用特权

评论回复
8
玛尼玛尼哄| | 2017-2-17 21:24 | 只看该作者
官方有这个芯片的例程吗,发来学习学习
手册上说有SPI接口吗,我觉得51的单片机是没有SPI接口的,都是用IO模拟SPI。

使用特权

评论回复
9
天灵灵地灵灵| | 2017-2-17 22:07 | 只看该作者
51单片机应该只有个UART串口,没有SPI,IIC,需要IO模拟。

使用特权

评论回复
10
slotg| | 2017-2-18 16:40 | 只看该作者
玛尼玛尼哄 发表于 2017-2-17 21:24
官方有这个芯片的例程吗,发来学习学习
手册上说有SPI接口吗,我觉得51的单片机是没有SPI接口的,都是用IO ...

N76E003 是有硬件 SPI 功能的。

使用特权

评论回复
11
slotg| | 2017-2-18 16:40 | 只看该作者
天灵灵地灵灵 发表于 2017-2-17 22:07
51单片机应该只有个UART串口,没有SPI,IIC,需要IO模拟。

N76E003 是有硬件 SPI 功能的。

使用特权

评论回复
12
734774645| | 2017-2-19 18:01 | 只看该作者
51单片机,基本上都是只有UART基本的232串口能力,其他的接口一般没有,需要IO来模拟,由于51接口都是准双向接口,因此很容易模拟那种通信。

使用特权

评论回复
13
fenshu| | 2017-11-23 18:19 | 只看该作者
新唐的SPI用于25Q80怎么一直出错

使用特权

评论回复
14
caidenghua| | 2018-1-18 21:56 | 只看该作者
//==============================================================
//SPCR.7    SSOE:
//    .6    SPIEN
//    .5    LSBFE
//    .4    MSTR
//    .3    CPOL
//    .2    CPHA
//    [1:0] SPR:   00-Fsys/2, 01-Fsys/4, 10-/8, 11-/16
//SRSR.7    SPIF
//==============================================================
void SPI_Initial(uint8_t divider)
{
        SPCR = MSTR|divider;
        SPSR |= DISMODF;        //SS General purpose I/O ( No Mode Fault )

        SPCR |= SPIEN;                //Enable SPI function
}

uint8_t SPI_WrRdByte(uint8_t byte)
{
        SPDR = byte;
        while(!(SPSR&SPIF));
        SPSR &= ~SPIF;
        byte = SPDR;
        return byte;
}

使用特权

评论回复
15
781354052| | 2020-3-12 09:47 | 只看该作者
官网下载最新BSP开发包即可!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

15

帖子

0

粉丝