Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Problems with ATMEGA164PA
Goto page 1, 2  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Sat May 12, 2018 9:26 am    Post subject: Problems with ATMEGA164PA Reply with quote

Hello,

I have been using ATMEGA164PA since its launch in a Xbee to Modbus converters and must have delivered over 3000 units till date, in another of my products, a Home automation control for 4 relays and a dimmer (Triac BT136) I had elected to use the same ATMEGA164PA.

List of observed problems....

1) Timer2 when initialized doesn't start up
2) Pin change interrupt for pins PCINT18 to PCINT23 gets triggered with Port Activity on some specific pins (PORTB.3)
3) I have connected switches for manual control on these pins & have I2C EEPROM on PinC.0, Pinc.1,
4) Have observed that with software i2c, the problem is more pronounced, my PCMAK2 = &h7C
5) Since TWI is available on this Chip I switched to the TWI interface, the problem of pin change interrupt triggered for portB activity is now only happening for PORTB.3


If any one has had similar issues...

1) Timer2 non functional

2) PCINT2 gets triggered for PortB activity, oh yes, I have checked this for other port pin change events, it only is happening with PCINT2


and can relate your experience here will appreciate your response and feedback.


Kind Regards

Madhav Tenneti

(BASCOM-AVR version : 2.0.8.1 )
Back to top
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2165

netherlands.gif
PostPosted: Sat May 12, 2018 4:18 pm    Post subject: Reply with quote

Hi Madhav,

You have to provide us some minimum code to reproduce the problem.
"timer2 not functional" is to wide problem.

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Sun May 13, 2018 4:06 am    Post subject: ATMEGA164PA Timer2 & PCINT2 (pin change) interrupt issue Reply with quote

Hello,

Since the Timer2 was not functional, I just modified the code to use Timer1, in this program. I am already using Timer0 for the 50Hz dimming using Zero cross hardware, Have no issues with Timer1 or Timer0, However Timer2 simply doesn't start.

My biggest concern is the Pin Change interrupt problem, have attached the relevant schematics too here as pdf's, Since we have this as a retrofit and the in wall switch box is compartmented (3 compartments) for Schnider Ulti range of switches, I had to split my circuit into three entities....

1) Power supply & Zero cross detector
2) CPU board with COM (XBEE), more of a multi functional CPU PCB so that I can use it else where in my other applications.
3) The 4 Relay Driver board.


All of the code works....

With data sent through XBEE, when PORTB sets or Resets the port pins, it triggers an interrupt (PCINT2), since the chk_wallswitches() sub gets executed, it doesn't let the PORTB data hold as per the sent command, the code would be just fine if the Pin change interrupt PCINT2 doesn't fire for the PORTB activity. Anyway have attached the complete code for your Kind reference.


Thanks in advance for looking into it.


Regards


Madhav Tenneti


Code:






'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          4M M164PA with Dimmer
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
$Regfile= "m164pdef.dat"
$Crystal = 16000000
$Baud = 9600

$hwstack = 256
$swstack = 128
$framesize = 164

Config PortB = Output

Config Timer0 = Timer, Prescale = 8
Config Timer2 = Timer, Prescale = 8

$lib "i2c_twi.lbx"
config scl = portc.0
config sda = portc.1
i2cinit
Config Twi = 100000

config pinc.2 = input
config pinc.3 = input
config pinc.4 = input
config pinc.5 = input
config pinc.6 = input
config pinc.7 = input

sw1 alias portc.2
sw2 alias portc.3
sw3 alias portc.4
sw4 alias portc.5
aux1 alias portc.6
aux2 alias portc.7

config pind.4 = output
config pind.5 = output
config pind.6 = output
config pind.7 = output

Fndmr Alias PortD.4
DDir Alias PortD.6
Rstt Alias PortD.7

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                              Variable Declaration
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dim Command as String * 15, P1 as String * 3, P2 as String * 3, P3 as String * 2
Dim P4 as string * 1, P5 as String * 2, P6 as String * 2
Dim UID as String * 3, Addr as string * 3
Dim Zrcs as bit, Kyb As Bit, , Zrcss As Bit,, Srlint As Byte

Dim Sw1stat as bit,Sw2stat as bit,Sw3stat as bit,sw4stat as bit
Dim Sw5stat as bit,sw6stat as bit,sw7stat as bit,sw8stat as bit

Dim Micsecs As word , Milsecs As Integer
Dim T2Micsecs as byte, T2Milsecs as word, T2Secs as byte, T2Mins as byte, T2Hrs as byte
Dim Pdata As Byte , Cdata As Byte , Sdata as byte
Dim M_add As Word , Base As Word , Raddress As Byte , Waddress As Byte
Dim Value As Byte , Address As Byte , Scnswprss As Bit
Dim Sceneval As Byte , Pinchng As Bit

Dim  Scene As Byte , Cardadd As Byte ,   Rlycomnd As Byte , Opseq As Byte

Dim Dvc As Byte
Dim Rxbyte As Byte, Comcnt As Byte

Dim Fn_id as byte, Fn_spd as byte, Fn_on as bit, Triac_on as byte, Dimerdelay as word

Dim Fnstat As Byte , Trip As Byte , Del As Word , F1spd As Byte

Dim Comvalid As Byte , Wrt As Byte , Ddata As Byte , Fspd As Byte , Fncntrl As Byte

Dim Txcomnd as string *14, PrtData as byte, Pdattxt as string * 2, Fspdtxt as string*1

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                 Dimmer Fan Speed Values to be used
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'  $SCIXXXDMF0105?    AC Output Voltage 130V
'  $SCIXXXDMF0106?   AC Output Voltage 165V
'  $SCIXXXDMF0107?   AC Output Voltage 225V
'  $SCIXXXDMF0108?   AC Output Voltage 230V
'  $SCIXXXDMF0109?   AC Output Voltage 235V
'  $SCIXXXDMF0110?   AC Output Voltage 242V


'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          System Sub routine Declarations
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Declare Sub Getuid()
Declare Sub Write_Uid()
Declare sub Store_curstat()
Declare Sub Recall_settings()
Declare Sub Make_settngs()
Declare Sub Get_Addr()
Declare Sub Run_system()
Declare Sub Serial_com()
Declare Sub Chk_wallsws()
Declare Sub Delayy()
Declare sub Comm_fn()
Declare Sub Comm_li()
Declare Sub Comm_sp()
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Light Controls
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Declare Sub Set_scene()
Declare Sub Set_device()
Declare Sub All_off()
Declare Sub Program_scene()
Declare Sub Write_settngs()
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             IIC Driver Routines
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Declare Sub Write_eeprmc64(m_add As Word , Value As Byte)
Declare Sub Read_eeprmc64(m_add As Word , Value As Byte)
Declare Sub Pcf8574read()
Declare Sub Pcf8574write()

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          System Main Routine
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Enable Interrupts
Enable Urxc
Enable Int0
Enable PCINT2

PCMSK2 = &H7C
Enable Timer0
Enable Timer2

Eicra = &H01




On Urxc Srlisr
On Timer0 Tmr0isr
On Timer1 Tmr1isr
On Int0 Zerocrss
On PCINT2 switches

Load Timer0, 200
Load Timer2, 200
Start Timer0
Start Timer2


Reset DDir
SEt Rstt
waitms 100
Call Get_addr
Call Recall_settings
Print "Addr:"; addr; ":::::"; "UID:";uid


Do
   Call Run_system
   If Zrcss = 1 then

      Select case Opseq
         Case is = 0:
         Case is = 1:

            Call Store_curStat
         Case is = 2:
            PortB = Cdata
            Call Store_curStat
         Case is = 3:
            PORTB = Sdata
            Call Store_curStat

         Case is = 4:
            Call Store_curStat
      End select

      Zrcss = 0
   End if

Loop
End
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Recall Stored Settings
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Recall_settings()
   For M_add = 5 to 9
      Call Read_eeprmc64(M_add, Value)
      Select case M_add
         Case is = 5:
            Opseq = Value
         Case is = 6:
            Scene = Value
         Case is = 7:
            Fspd = Value
         Case is = 8:
            Cdata = Value
         Case is = 9:
            Sdata = Value
      End select
   Next
End sub

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Store Current Status
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Store_CurStat()
   For M_add = 5 to 9
      Select Case M_add
         Case is = 5:
            Value = Opseq
         Case is = 6:
            Value = Scene
         Case is = 7:
            Value = Fspd
         Case is = 8:
            VALUE = Cdata
         Case is = 9:
            Value = Sdata
      End select
      Call Write_Eeprmc64(M_add, Value)
    Next
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Run System
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Run_system()
   Call Serial_com
   Call Chk_wallsws

End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Get UID
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Getuid()
   Local Uih As String * 3
   Uih = ""
   For M_add = 10 To 12
      Call Read_eeprmc64(m_add , Value)
      If Value = 255 Then
         Uih = "XXX"
         Exit For
      Else
         Uih = Uih + Chr(value)
      End If
   Next
   Uid = Uih
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Write UID
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Write_uid()
   Local Tstt As String * 1
   Uid = Mid(command , 2 , 3)
   For M_add = 10 To 12
      Select Case M_add
         Case Is = 10:
            Tstt = Mid(uid , 1 , 1)
            Value = Asc(tstt)
         Case Is = 11:
            Tstt = Mid(uid , 2 , 1)
            Value = Asc(tstt)
         Case Is = 12:
            Tstt = Mid(uid , 3 , 1)
            Value = Asc(tstt)
      End Select
      Call Write_eeprmc64(m_add , Value)
   Next
   Print UID
End Sub

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Get Addr
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Get_Addr()
   Local ID as byte
   Local Mask As Byte
   Local level as byte
   Local Room as byte
   Local Cardadd As byte
   Dvc = 1
   Call Pcf8574read
   Id = Value
   Mask = &H03
   Level = Id And Mask
   Mask = &H1C
   Room = Id And Mask
   Shift Room , Right , 2
   Mask = &HE0
   Cardadd = Id And Mask
   Shift Cardadd , Right , 5
   Addr = Str(Level)+Str(Room)+Str(Cardadd)
   Call Getuid

End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Serial Comm
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Serial_Com()
   Local Checktag as string * 4
   If Srlint = 1 then
      P1 = Mid(command , 2 , 3)
      P2 = Mid(Command , 5 , 3)
      P3 = Mid(command , 8 , 2)
      P4 = Mid(command , 10 , 1)
      P5 = Mid(command , 11 , 2)
      P6 = Mid(command , 13 , 2)
      Call Get_addr
      If P1 = UID then
         If P2 = Addr Then
            Select case P3
               Case is = "LI":
                  Call Comm_Li
               Case is = "SP":
                  Call Comm_Sp
               Case is = "OT":
                  Checktag = P5 + P6
                  If P4 = "O" then
                     If Checktag = "ROOM" then
                        opseq = 7
                        Cdata = 0
                        Fspd = 0

                     End if
                  End If
               Case is = "AL":
                  Checktag = P5 + P6
                  If P4 = "L" then
                     If Checktag = "OOFF" then
                        opseq = 7
                        Cdata = 0
                        Fspd = 0

                     End if
                  End If
            End select
         Elseif P2 = "AAA" then
            Checktag = P5 + P6
            Select case P3
               Case is = "OT":
                  If P4 = "O" then
                     If Checktag = "HOME" then
                        opseq = 7
                        Cdata = 0
                        Fspd = 0

                     End if
                  End If
               Case is = "IN":
                  If P4 = "S" then
                     If Checktag = "HOME" then

                     End if
                  End If
            End select
         End if
      Else
         If P3 = "SP" then
            If P4 = "*" then
               If P5 = "20" then
                  Call Write_uid
               End if
            End if
         End If
      End if
      Srlint = 0
      Comcnt = 0
      Command = ""
      Enable Urxc
   End if

End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Comm Fan
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
sub comm_fn()
   Local Scale as byte
   Opseq = 4
   If Fn_spd > 0 then
      Fn_on = 1
      Scale = 10 - Fn_spd
      dimerdelay = scale
   Else
      Fn_on = 0
   End if
   Print "FNSpd:";fn_spd;":::";"Dimerdelay:";Dimerdelay
end sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Comm Lights
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
sub comm_li()

   Select case P4
      Case is = "S":
         Opseq = 1
         Scene = Val(P6)
         Call Set_scene
      Case is = "I":
         Opseq = 2
         Call Set_device
      Case is = "F"
         Fn_id = Val(P5)
         Fn_spd = Val(P6)
         Call Comm_Fn
   End select
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Check Wall Switches
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Chk_Wallsws()
   if Kyb = 1 then
      Print "Pinchng Interrupt"

      If pinC.2 = 0 then
         Opseq = 3
         Del = 30
         Call Delayy
         Sdata.0 = 1
         Set PortB.0
      Elseif PINC.2 = 1then
         Opseq = 3
         Del = 30
         Call Delayy
         Sdata. 0 = 0
         Reset PortB.0
      End if

      If PinC.3 = 0 Then
         Opseq = 3
         Del = 30
         Call Delayy
         Sdata.1 = 1
      Else
         Opseq = 3
         Del = 30
         Call Delayy
         Sdata.1 = 0
      End if

      If PinC.4 = 0 then
         Opseq = 3
         Del = 30
         Call Delayy
         Sdata.2 = 1
      Else
         Opseq = 3
         Del = 30
         Call Delayy
         Sdata.2 = 0
      End if

      If PinC.5 = 0 then
         Opseq = 3
         Del = 30
         Call Delayy
         Sdata.3 = 1
      Else
         Opseq = 3
         Del = 30
         Call Delayy
         Sdata.3 = 0
      End if

      If PinC.6 = 0 then
         Opseq = 3
         Del = 30
         Call Delayy
         Fn_on = 1
      Else
         Opseq = 3
         Del = 30
         Call Delayy
         Fn_on = 0
      End if

      If PinC.7 = 0 then

      End if
      Kyb = 0
      Enable pcint2

   End if
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Is comcode SP
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub comm_sp()
    Select Case P5
      Case Is = "10":
      Case Is = "20":
         Call Write_uid
      Case Is = "30":
         Scene = Val(P6)
         Call Program_scene
      Case Is = "40":
    End Select
End Sub

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Program Scene
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Program_scene()
   Select Case Scene
      Case Is = 1:
         Base = 100
         Call Write_settngs
      Case Is = 2:
         Base = 120
         Call Write_settngs
      Case Is = 3:
         Base = 140
         Call Write_settngs
      Case Is = 4:
         Base = 160
         Call Write_settngs
      Case Is = 5:
         Base = 180
         Call Write_settngs
      Case Is = 6:
         Base = 200
         Call Write_settngs
      Case Is = 7:
         Base = 220
         Call Write_settngs
      Case Is = 8:
         Base = 240
         Call Write_settngs
   End Select
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Write Settings
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Write_settngs()
   Local Parm As Word
   Local Setvals As String * 3
   Disable Urxc

   For Parm = 0 To 8
      Input Setvals Noecho
      M_add = Base + Parm
      Value = Val(setvals)
      Call Write_eeprmc64(m_add , Value)
      Print "Parm:" ; Parm ; "   " ; "M_add:" ; M_add ; " Val:" ; Value
      Del = 30
      Call Delayy
   Next
   Enable Urxc
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                   Make Settings
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Make_settngs()
   Local Endaddr As Word
   Local Parm As Byte
   Local Mask As Byte
   Local Onstat As Byte
   Local Oth As Byte
   Endaddr = Base + 7
   Parm = 0
   For M_add = Base To EndAddr
      Call Read_eeprmc64(m_add , Value)
      If Parm >= 0 and Parm <= 7 then

      Elseif Parm = 8 then
         Pdata = Value
      End if
      Del = 25
      Call Delayy
      Incr Parm
   Next
End Sub

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                   Set Scene
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Set_scene()
   Srlint = 1
   Select Case Scene
      Case Is = 0:
         Call All_off
      Case Is = 1:
         Base = 100
         Call Make_settngs
      Case Is = 2:
         Base = 120
         Call Make_settngs
      Case Is = 3:
         Base = 140
         Call Make_settngs
      Case Is = 4:
         Base = 160
         Call Make_settngs
      Case Is = 5:
         Base = 180
         Call Make_settngs
      Case Is = 6:
         Base = 200
         Call Make_settngs
      Case Is = 7:
         Base = 220
         Call Make_settngs
      Case Is = 8:
         Base = 240
         Call Make_settngs
   End Select
   Micsecs = 0

End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                All Off
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub All_off()
   Pdata = 0
   Cdata = 0
   Ddata = 0

End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Set Device
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Set_device()
   Select Case P5
      Case Is = "01":
         If P6 = "01" Then
            Cdata.0 = 1
         Elseif P6 = "00" then
            Cdata.0 = 0
         End If
      Case Is = "02":
         If P6 = "01" Then
            Cdata.1 = 1
         Elseif P6 = "00" then
            Cdata.1 = 0
         End If
      Case Is = "03":
         If P6 = "01" Then
            Cdata.2 = 1
         Elseif P6 = "00" then
            Cdata.2 = 0
         End If
      Case Is = "04":
         If P6 = "01" Then
            Cdata.3 = 1
         Elseif P6 = "00" then
            Cdata.3 = 0
         End If
      Case Is = "11":
         If P6 = "11" Then
            Cdata = &H0F
         Elseif P6 = "00" then
            Cdata = &H00
         End if
   End Select
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Delay
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Delayy()
   T2Micsecs = 0
   T2Milsecs = 0
   Do

   Loop Until T2Milsecs >= Del
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IIC EEPROM routines  @@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                              Write Operation
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Write_eeprmc64(m_add As Word , Value As Byte)
   Local M_ladd As Byte
   Local M_hadd As Byte
   Waddress = &HA0
   Raddress = &HA1
   M_ladd = Low(m_add)
   M_hadd = High(m_add)
   I2cstart
   I2cwbyte Waddress
   I2cwbyte M_hadd
   I2cwbyte M_ladd
   I2cwbyte Value
   I2cstop
   'Del = 10
   'Call Delayy
   Waitms 100
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                              Read Operation
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Read_eeprmc64(m_add As Word , Value As Byte)
   Local M_ladd As Byte
   Local M_hadd As Byte
   Waddress = &HA0
   Raddress = &HA1
   M_ladd = Low(m_add)
   M_hadd = High(m_add)
   I2cstart                                                 'generate start
   I2cwbyte Waddress                                        'slave adsress
   I2cwbyte M_hadd
   I2cwbyte M_ladd                                          'address of EEPROM
   I2cstart                                                 'repeated start
   I2cwbyte Raddress                                        'slave address (read)
   I2crbyte Value , Nack                                    'read byte
   I2cstop                                                  'generate stop
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@ PCF8574 operations @@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Read Operation
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Pcf8574read()
   If Dvc = 1 Then
      Waddress = &H40
      Raddress = &H41
   Elseif Dvc = 2 Then
      Waddress = &H42
      Raddress = &H43
   End If
   I2cstart                                                 'generate start
   I2cwbyte Raddress                                        'I2C address
   I2crbyte Value , Nack                                    'read byte
   I2cstop                                                  'generate stop
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Write Operation
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Pcf8574write(byval Value As Byte)
   If Dvc = 1 Then
      Waddress = &H40
      Raddress = &H41
   Elseif Dvc = 2 Then
      Waddress = &H42
      Raddress = &H43
   End If
   I2cstart                                                 'start condition
   I2cwbyte Waddress                                        ' I2C address
   I2cwbyte Value                                           'write data
   I2cstop                                                  'stop condition
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@  System Interrupts @@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          Zerocross Detector interrupt
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Zerocrss:
   'EIFR = &H01
   Zrcss = 1
   'Disable Int0
   Micsecs = 0
   milsecs = 0
   Triac_on = 0
   if dimerdelay = 0 then
      Reset fndmr
   else
      set fndmr
   end if
   if Fn_on = 0 then
      set Fndmr
   End if
Return


Switches:
   Kyb = 1

Return


'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          Serial Interrupt Port0
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Srlisr:
   Rxbyte = Udr
   If Chr(rxbyte) = "$" Then
      Comcnt = 1
      Command = ""
   End If
   If Comcnt >= 1 Then
      Incr Comcnt
      Command = Command + Chr(rxbyte)
      If Chr(rxbyte) = "?" Then
         If Comcnt >= 15 Then
            Disable Urxc
            Srlint = 1
         Else
            Command = ""
            Comcnt = 0
         End If
      End If
   End If
Return
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                           Timer 0 Interrupt
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Tmr0isr:
   if Triac_on = 2 then
      Triac_on = 1
      Set FnDmr
   End if
   if dimerdelay <> 0 then
     Incr micsecs
     if micsecs >= 10 then
         micsecs = 0
         incr milsecs
        If Milsecs >= dimerdelay  And Triac_on = 0  then
           If fn_on = 1 then
              Reset Fndmr
              Triac_on = 2
           End if
        End if
     end if
   end if

   Load Timer0, 200
Return
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                           Timer 2 Interrupt
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Tmr2isr:
   Incr T2Micsecs
   If T2Micsecs >= 10 then
      T2Micsecs = 0
      Incr T2Milsecs
      If T2Milsecs >= 1000 then
         T2Milsecs = 0
         Incr T2Secs
         If T2Secs >= 60 then
            T2Secs = 0
            Incr T2Mins
            If T2Mins >= 60 then
               T2mins = 0
               Incr T2Hrs
               If T2Hrs >= 23 then
                  T2Hrs = 0
               End if
            End if
         End if
      End if
   End if
   Load Timer2, 200
Return[code][/code]
 
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1135

poland.gif
PostPosted: Sun May 13, 2018 7:03 am    Post subject: Reply with quote

I download the code you attach to the post and my Code Explorer crying about the errors. Do You use Code Explorer?
Same for the using reserved words like UID. Using them for name of your variables can end wrong...
Also using Bits for the flags in the interrupt routines is not a good practice. Better is to assign 1 into the Byte

Do you see those two comma`s?
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2335

blank.gif
PostPosted: Sun May 13, 2018 7:14 am    Post subject: Reply with quote

There's no reason, that PB3 via software affects PCINT on PortC, so I suspect some hardware-crosstalk - in case PCINT triggers at all, which can be tested by blinking a LED within PCINT-ISR.
Timer2 may be actually running, but does nothing beside running, it is neither read, nor an ISR-vector is defined for it.
Back to top
View user's profile
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Sun May 13, 2018 10:28 am    Post subject: ATMEGA164 Timer0 issue & PCINT2 Problems Reply with quote

Yes of course, I use Code Explorer, here is a screenshot from my computer...

Timer2 can be tested by assigning Del some value and calling an event like setting a port pin High or transmitting a known string from the UART 0, This simply doesn't happen so that is how I am sure the Timer2 has a problem...

I have included the schematics too, there is no fouling of the hardware anywhere

Thanks for your comments.

Kind Regards

Madhav Tenneti
Back to top
View user's profile Visit poster's website
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Sun May 13, 2018 10:41 am    Post subject: ATMEGA164PA Timer2 Issue Reply with quote

As I had informed earlier, I had switched to using Timer1, For posting the code here I changed all Timer1 Instances to Timer2 and I forgot to change the Interrupt Vector branch out from Timer1 to Timer2....


Was posted as …


Enable Interrupts
Enable Urxc
Enable Int0
Enable PCINT2

PCMSK2 = &H7C
Enable Timer0
Enable Timer2

Eicra = &H01

On Urxc Srlisr
On Timer0 Tmr0isr
On Timer1 Tmr1isr
On Int0 Zerocrss
On PCINT2 switches

Load Timer0, 200
Load Timer2, 200
Start Timer0
Start Timer2

Should have been...

Enable Interrupts
Enable Urxc
Enable Int0
Enable PCINT2

PCMSK2 = &H7C
Enable Timer0
Enable Timer2

Eicra = &H01

On Urxc Srlisr
On Timer0 Tmr0isr
On Timer2 Tmr2isr
On Int0 Zerocrss
On PCINT2 switches

Load Timer0, 200
Load Timer2, 200
Start Timer0
Start Timer2
Back to top
View user's profile Visit poster's website
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Sun May 13, 2018 10:51 am    Post subject: ATMEGA164PA Timer2 Issue Reply with quote

As I had informed earlier, I had switched to using Timer1, For posting the code here I changed all Timer1 Instances to Timer2 and I forgot to change the Interrupt Vector branch out from Timer1 to Timer2....


Was posted as …


Enable Interrupts
Enable Urxc
Enable Int0
Enable PCINT2

PCMSK2 = &H7C
Enable Timer0
Enable Timer2

Eicra = &H01

On Urxc Srlisr
On Timer0 Tmr0isr
On Timer1 Tmr1isr
On Int0 Zerocrss
On PCINT2 switches

Load Timer0, 200
Load Timer2, 200
Start Timer0
Start Timer2

Should have been...

Enable Interrupts
Enable Urxc
Enable Int0
Enable PCINT2

PCMSK2 = &H7C
Enable Timer0
Enable Timer2

Eicra = &H01

On Urxc Srlisr
On Timer0 Tmr0isr
On Timer2 Tmr2isr
On Int0 Zerocrss
On PCINT2 switches

Load Timer0, 200
Load Timer2, 200
Start Timer0
Start Timer2
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2335

blank.gif
PostPosted: Sun May 13, 2018 12:03 pm    Post subject: Re: ATMEGA164PA Timer2 Issue Reply with quote

madhav1080 wrote:
As I had informed earlier, I had switched to using Timer1, For posting the code here I changed all Timer1 Instances to Timer2 and I forgot to change the Interrupt Vector branch out from Timer1 to Timer2....
Was posted as …

I do not care how it was posted, can read that myself, sure it had to be: On Timer2...

The main question is: Was it compiled with the wrong vector declaration or did you only post it with wrong declaration?
Also, if compiled with proper vector declaration and flashed, does it work?
To learn whether a timer works on the real chip. it suffices to toggle a led within the ISR, if it lights up dimmed, there's a signal.

What's the reason btw. for your double posts? This topic you've posted twice and your previous post also twice, I suggest to check how this forum is properly used.
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2335

blank.gif
PostPosted: Sun May 13, 2018 1:07 pm    Post subject: Reply with quote

EDC wrote:
Also using Bits for the flags in the interrupt routines is not a good practice.

It's not about good practice or not, it's rather that the result from the PCINT may get lost.
The problem is that a bit is stored within one host-byte and the command Kyb = 0 is translated by the compiler into several assembler instructions, which does 'read -> modify -> write' of the data byte where the bit is stored to.
In case a PCINT is executed immediately after the 'read ->' in this sequence, any change of Kyb within the ISR will be lost.
It can be solved by encapsulating Kyb = x with Disable/Enable Interrupts.
Quote:
Better is to assign 1 into the Byte

That's not much better, as it can show the same effect, with the only difference that not more bits hosted in the same byte are affected.
Code:
Dim Kyb As Byte
A Kyb = 0
 

is translated into something like that:
Code:
!LDI   R18, 0
!STS {Kyb}, R18

In case PCINT hits as !LDI R18, 0 is executed, R18 is saved by the ISR and subsequently Kyb is altered within the ISR.
After return from the ISR, R18 is restored, in this case with value 0, which in turn is written into Kyb, resulting in Kyb is 0, while obviously it should be 1 after the ISR.
This problem exists with any data used by main code and ISR.
Even it seems unlikely that this coincidence happens, means have the interrupt hitting exactly at a certain moment of execution, it is possible, as more frequent, as more likely.
And then it means random and difficult to find malfunction of the device.

In this certain case, where only a flag is set within the ISR, it is basically much easier without PCINT-ISR at all.
PCIF2, that's the interrupt-flag within PCIFR for PCINT2, is set independently whether interrupts are enabled or a vector is declared.
Thus it can be used like that:
Code:
Sub Chk_Wallsws()
   if PCIFR.PCIF2 = 1 then
      PCIFR.PCIF2 = 1   ' clear interrupt flags by writing 1 to them
         Print "Pinchng Interrupt"

This, as well the accompanying ISR can be removed:
Code:
Enable PCINT2
On PCINT2 switches
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2335

blank.gif
PostPosted: Sun May 13, 2018 1:09 pm    Post subject: Reply with quote

Back to top
View user's profile
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Sun May 13, 2018 4:42 pm    Post subject: Sorry for the double posts Reply with quote

This was definitely not intentional, I am using Internet explorer and could be an issue with it, you may have noticed that the first post was also twice.

I am truly sorry the Preview button is automatically initiating posting to the forum. and I can't see this until I use the submit button, Will be careful here after.


ONCE AGAIN MY APPOLOGIES


Madhav Tenneti
Back to top
View user's profile Visit poster's website
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Sun May 13, 2018 5:07 pm    Post subject: ATMEGA164 Timer2 Issue Reply with quote

Well, this is from a system already in place, I am now adding mechanical switchs interface using the pin change interrupt, I have used pin change interrupt on ATMEGA88PA & ATMEGA328P in numerous projects and have never had an issue. Like wise I utilise all the Three timers in many of my applications, again on the two chips mentioned or for that matter ATMEGA128A or ATMEGA2560, have never had problem with Timer2.

When the timer2 is used the code doesnt move gets stuck at the first call to the Sub Delayy. However the same code with the timer changed to Timer1 has no issues. and executes exactly as programmed.

Taken note of your suggestion regarding using bit variables, Thank you will update myself, I usually keep very little code in my ISR routines, to check interrupt latency, usually setting a flag, check the flag in the main code Sub, always disable the interrupt in the ISR, and clear the flag, enable the interrupt after executing the code in the appropriate sub.

However I had to do away with this practice as it is causing multiple triggers several while the Switch is going down and several other while the switch is released. However when I don't disable the interrupt and just set the flag it gets triggered only twice once while going down and second time when released. This behaviour was particularly observed on the SCHNIDER ULTI RANGE of Switches.

Kind Regards

Madhav Tenneti
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2335

blank.gif
PostPosted: Sun May 13, 2018 9:18 pm    Post subject: Re: ATMEGA164 Timer2 Issue Reply with quote

madhav1080 wrote:
to check interrupt latency, usually setting a flag, check the flag in the main code Sub, always disable the interrupt in the ISR, and clear the flag, enable the interrupt after executing the code in the appropriate sub.

You are aware, that interrupts are automatically disabled while ISR-execution?
If a pin-change occurs after disabling the pc-interrupt, PCIF2 will be set again, which will result in immediate execution of the interrupt after re-enabling it.

Also: better set INT0-mode before enabling it:
Code:
Eicra = &H01
Enable Int0

You do it in the moment the other way around, this way INT0 low-level is active. In case PD2 is kept low, it leads to continuously execution of Zerocrss, till the command about EICRA is reached.
Configuration for interrupts need to come first, enabling second. Nothing serious, but not clean programmed either.

An AVR-Studio simulation showed that:
Code:
Start Timer2

does not work as expected, it stops Timer2, instead of starting it.
Leave out this command, as timers run automatically after configuration anyway.
Only if you need to start and stop timers you need to write to TCCR2B yourself to circumvent this bug.
Report it to support.
Back to top
View user's profile
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Mon May 14, 2018 2:51 am    Post subject: ATMEGA164PA Timer2 Issue Reply with quote

Many many THANKS, I just needed confirmation on the Timer2 issue, sure will not use START TimerX to initiate the timers...

Noted your suggestion about setting the interrupt mode first and Then Enabling it, will also do the same in ISR for INT0. Have no issues here either as the Hardware ensures that there is a Square wave (50% Duty cycle) tied to the INT0 pin, Will folllow you recomendation here after.

I am still not very clear about the PCINT2 triggered for the PORTB activity, maybe I should just write the code for testing this and then add the rest, on couple of occasions this helped solve such problem.

Once again Appreciate your TIME and FEEDBACK, THANK YOU



Kind Regards

Madhav Tenneti
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum