Page 2 of 2 FirstFirst 1 2
Results 11 to 17 of 17

Thread: uncertain working with 08M2

  1. #11
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    19,767

    Default

    @ westaust55 : Thanks for investigating.

    This seems to be a simulator issue which I will pass along for investigation. Physical chips should only action the SETINT and re-enable interrupts on the primary RETURN.

  2. #12
    New Member
    Join Date
    Dec 2011
    Location
    brittany, france
    Posts
    7

    Default

    it's getting more and more bizarre,

    in fact I was so impatient to test the code given by Westaust55 that I put it directly on the 08M2 without simulating, and the fact is that it works. But now as I hear you discuss, I simulated with the programming editor and it doesn't work.... the program keeps interrupting even if CubeDetect is activated before simulation, and then it continuously jumps from interrupt: to attente: without clearing the interruption even if CubeDetect is high...
    In the code that I put onto the chip, there isn't any RETURN at the end of the interrupt: , they are at the end of the secondary routines.

  3. #13
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    19,767

    Default

    Quote Originally Posted by YCPT View Post
    In the code that I put onto the chip, there isn't any RETURN at the end of the interrupt: , they are at the end of the secondary routines.
    It's also getting more confusing; if you used westaust55's code there is a return, when the interrupt routine falls through into the "attente:" labelled code.

    If you are using some other code it may be worth posting it as it's not clear what you have.

  4. #14
    New Member
    Join Date
    Dec 2011
    Location
    brittany, france
    Posts
    7

    Default

    Yes, you're right, there is also a problem of understanding each other as my explanations are not very clear.

    here is the code what I use... of course there is a return which would finally be hit after the interrupt, but it is in attente1 or attente2, not directly in the interrupt, that's what I was trying to say :
    Code:
    #PICAXE 08M2
    SYMBOL CubeDetect = pinC.1
    SYMBOL CubeReset = pinC.3
    SYMBOL StartStop =  C.2
    SYMBOL TimerReset =  C.4
    
    
    SYMBOL CubeOn = 1 ; when cube is on the plate
    SYMBOL CubeOff = 0 ; when the plate is empty
    SYMBOL Delai1 = 20
    SYMBOL Delai2 = 10
    
    
    Init:
    low StartStop
    low TimerReset
    b2=0
    setint %00000000,%00000010 ; interrupt on Input C.1 (CubeDetect) low/off
    
    
    main:
    	DO
    		pause 50
    		low StartStop 
    		low TimerReset
    		IF CubeDetect = CubeOn AND b2 = 0 THEN
    	    		PAUSE 50
    	    		IF CubeDetect = CubeOn THEN
    	    			b2 = 1
    			ENDIF
    		ENDIF
    	LOOP 
     
    	
    interrupt: 
    	IF b2= 0 THEN attente1
    	
    	if CubeDetect = CubeOn   then 
    		pause Delai2
    		if CubeDetect = CubeOn then impufrontdescendant
    		goto attente2
    	endif
    	
    	
    	if CubeDetect = CubeOff  then
    		pause Delai1
    		if CubeDetect = CubeOff then impufrontmontant
    		goto attente1
    	endif
    	
    	
    attente1:
    
    	setint %00000000,%00000010 ; interrupt on Input C.1 low
    	return
    	
    attente2:
    
    	setint %00000010,%00000010 ; interrupt on Input C.1 high
    	return
    	
    impufrontmontant:
    	high StartStop                                  'start chronometer
    	pause 60
    	low StartStop
    	setint %00000010,%00000010 ; interrupt on Input C.1 high 
    	return
    
    
    impufrontdescendant:
    	high StartStop                                     'stop chronometer
    	pause 60
    	low StartStop
    
    
    	do while CubeReset = 0
    		pause 1
    	loop 
    	pause 300
    
    
    	if CubeReset= 1 then	; test if it is a longer reset press
    	high StartStop                                   
    	pause 60
    	low StartStop			  ; if so activate the start stop again
    		pause 50
    	endif	
    	
    	high TimerReset                                     
    	pause 60
    	low TimerReset ; now reset the timer
    	pause 50
    	high TimerReset                                     
    	pause 60
    	low TimerReset; and a second time to be sure
    
    	do while CubeDetect = CubeOff
    		low TimerReset
    	loop
    	let b2=0
    	setint %00000000,%00000010 ; interrupt on Input C.1 low
    	return
    thank you again for the interest you have on this topic, I find this very interesting because it helps to get all the tricks (and also some basics that I lack) of picaxe programming, but don't worry too much as the whole gadget is working properly... Delai1 and delai2 are delays I added for debouncing the switch.

    Thanks ! JF

  5. #15
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    19,767

    Default

    Quote Originally Posted by westaust55 View Post
    That my edited version solved the primary problem suggests the same situation exists in firmware but not tested in firmware by myself with actual chip.
    Just an update to say that the issue seems to be only with simulation and not with physical chips.

  6. #16
    Moderator
    Join Date
    Mar 2008
    Location
    Western Australia
    Posts
    11,068

    Default

    I have in fact this evening just done a text with an actual chip and concur that the firmware in physical chips does as expected.

  7. #17
    New Member
    Join Date
    Dec 2011
    Location
    brittany, france
    Posts
    7

    Default

    many thanks for your investigation and support :-)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •