Bonjour, j'utilise une liaison SPI pour envoyer un mot en Hexadécimale de 8 bits qui est "A9"=10101001
J’utilise un PIC18F4550 et un oscilloscope pour visualiser le graphe.
Ci joint le schéma, le programme du PIC en BASIC PROTON, et le graphe relevé par l'oscilloscope.
Il n y a aucun problème d'après ce que je vois appart que je ne vois pas les bits START et STOP ou celui de Parité, je ne sais pas pour quoi, avez vous des commentaires ?
simul.JPGoscilloscope.JPG
Le programme :
Device = 18F4550
Declare XTAL = 40 ' Set the oscillator speed to 48MHz (using a 20MHz crystal)
Declare USBDIV = 2 ' USB clock source comes from the 96 MHz PLL divided by 2
Declare FOSC = HSPLL_HS ' HS oscillator, PLL enabled, HS used by USB
Declare FCMEN = OFF ' Fail-Safe Clock Monitor disabled
Declare IESO = On ' Oscillator Switchover mode enabled
Declare PWRT = On ' PWRT enabled
Declare BOR = OFF ' Brown-out Reset disabled in hardware and software
Declare BORV = 0 ' Maximum setting
Declare VREGEN = On ' USB voltage regulator enabled
Declare WDT = OFF ' HW Disabled - SW Controlled
Declare WDTPS = 1 ' 1:1
Declare MCLRE = On ' MCLR pin enabled; RE3 input pin disabled
Declare LPT1OSC = OFF ' Timer1 configured for higher power operation
Declare PBADEN = OFF ' PORTB <4:0> pins are configured as digital I/O on Reset
Declare CCP2MX = On ' CCP2 input/output is multiplexed with RC1
Declare STVREN = OFF ' Stack full/underflow will not cause Reset
Declare LVP = OFF ' Single-Supply ICSP disabled
Declare XINST = OFF 'Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
Declare Debug = OFF 'Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
Declare CP0 = OFF ' Block 0 (000800-001FFFh) not code-protected
Declare CP1 = OFF ' Block 1 (002000-003FFFh) not code-protected
Declare CP2 = OFF ' Block 2 (004000-005FFFh) not code-protected
Declare CPB = OFF ' Boot block (000000-0007FFh) not code-protected
Declare CPD = OFF ' Data EEPROM not code-protected
Declare WRT0 = OFF ' Block 0 (000800-001FFFh) not write-protected
Declare WRT1 = OFF ' Block 1 (002000-003FFFh) not write-protected
Declare WRT2 = OFF ' Block 2 (004000-005FFFh) not write-protected
Declare WRTB = OFF ' Boot block (000000-0007FFh) not write-protected
Declare WRTC = OFF ' Configuration registers (300000-3000FFh) not write-protected
Declare WRTD = OFF ' Data EEPROM not write-protected
Declare EBTR0 = OFF ' Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
Declare EBTR1 = OFF ' Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
Declare EBTR2 = OFF ' Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
Declare EBTRB = OFF ' Boot block (000000-0007FFh) not protected from table reads executed in other blocks
Symbol CS = PORTC.4 ' SPI eeprom CS line
Symbol SCK = PORTD.0 ' Clock pin
Symbol SI = PORTC.7 ' Data in pin
Symbol SO = PORTC.6 ' Data out pin
Dim Addr As Word ' Address
Dim B0 As Byte ' Data
‘Subroutine to write data at addr in serial EEPROM
bcl:
CS = 0 ' Enable serial EEPROM
SHOut SO, SCK, msbfirst, [$A9] ' Send write enable command
CS = 1 ' Disable to execute command
DelayMS 10 ' Delay 10ms after each write
GoTo bcl:
Return
-----