Thanks for this reply ...
I will try this ...
regards
For more information about my code:
[code:1:805b693b93]
'$sim
$regfile = "m88pdef.dat"
$crystal = 4000000
$hwstack = 35
$swstack = 40
$framesize = 50
$baud = 600 ' 19200
'======================================================== CONFIGURATION DE l'I2C ===============================================================
$lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI
Config Scl = Portc.5 ' pull up on this pin 1K
Config Sda = Portc.4 'pull up on this pin 1K
Config Twi = 200000
I2cinit
'-------------------------------------------------------------------------------------------------------------------------------------------------
'=========================================================== CONFIGURATION DU PWM ===============================================================
Config Timer0 = Pwm , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Start Timer0
Config Timer1 = Pwm , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Start Timer1
Config Timer2 = Pwm , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Start Timer2
'Pwm0a = touche 1
'Pwm0b = touche 2
'Pwm1a = touche 3
'Pwm1b = touche 4
'Pwm2a = touche Haut
'Pwm2b = touche bas
'========================================================== CONFIGURATION DES PORTS =======================================================================
Config Pinb.0 = Input
Prox Alias Pinb.0
Config Portb.7 = Output
Mosfet Alias Portb.7
Config Portc.1 = Output
Led1_lisere Alias Portc.1
Config Portc.0 = Output
Led2_lisere Alias Portc.0
Config Pinc.7 = Input
Adc_batt Alias Pinc.7
'===================================================== CONFIGUATION DES VARIABLES ET CONSTANTES ======================================================
Dim A As Byte
Dim Prox_isr_variable As Bit
Dim Flag_prox_pwm As Bit
Dim Valeur As Byte
Dim Adress_byte As Byte
Dim Valeur_byte As Byte
'================================================ CONFIGURATION DE L'INTERRUPT ===================================================================
Enable Interrupts
Enable Pcint0 ' configuration de l'interrupt PCINT0 (portB.0) en mode falling avec un mask sur B.0
On Pcint0 Prox_isr
Config Int0 = Change
Pcmsk0 = &B00000001
'====================================================================================================================================================
Pwm1a = 50
Wait 1
pwm1a = 0
Main:
'Print "main"
'(
Print " Prox_isr_variable" ; Prox_isr_variable
Select Case Prox_isr_variable
Case 0:
If Pwm0a > 0 Or Led1_lisere = 1 Or Led2_lisere = 1 Then Gosub Prox_detectee_out
Case 1:
If Pwm0a < 50 Or Led1_lisere = 0 Or Led2_lisere = 0 Then Gosub Prox_detectee
End Select
')
I2cstart
I2cwbyte &H80
I2cwbyte &H35
I2cstart
I2cwbyte &H81
I2crbyte Valeur_byte , Nack
'Waitms 2
I2cstop
Waitms 5
Print "valeur= " ; Valeur_byte
Goto Main
Prox_isr:
Print "interrupt"
If Pinb.0 = 1 Then
Prox_isr_variable = 0
Else
Prox_isr_variable = 1
End If
Return
[/code:1:805b693b93]
thanks everybody
↧