• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

test please delete

Collapse
This is a sticky topic.
X
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Very tired.

    If I go for a nap, then when I wake up it will be bedtime

    Comment


      I had the rest of the scouse for my tea. Very filling

      Today having been quite productive, I may try for a comparatively early night, and see if I can manage the same tomorrow. Not yet though

      Comment


        Join IPSE

        Comment


          Comment


            Morning all.

            I'm warm for the first time today.

            Comment


              Originally posted by NickFitz View Post
              Aren't you supposed to define constants to represent the magick numbers with something meaningful, like THING_BOGGLE_REGISTER = 1 << 7 and so on?
              That probably depends on how much of a hurry you're in to do something else at the same time.

              As it transpires, it never got used anyway.

              And one of the magick numbers is, indeed, #defined.

              Didn't make it any more obvious WTF was going on though.

              The commented out additional 11 lines of code didn't help much either.

              Why I named the interrupt flag as "counter" is truly mysterious.

              It probably came from some other POS that I found somewhere.

              Code:
              #define RELOAD_VALUE 8 //generates a 1ms pulse with 4MHz xtal by counting 250 - 2 = 248 
              
              unsigned char counter;
              void interrupt() {
                counter++;		//indicate we've had an int
                TMR0 = RELOAD_VALUE;
                INTCON = 0x20;         // enable tmr0 ints & clear tmr0 int flag
              }
              
              void main()
              {
              TRISIO = 0x3b;                  //all gpio as inputs, GPIO.2 PIN 5 as output b'0011 1011'
              
              CMCON = 0x07;                   // comparators off, GPIO 0 & 1 & 2 as digitals
              
              OPTION_REG = 0x81; //pullups disabled, prescaler div by 4 for TMR0: fosc /4 then /4 = 4us: 250 of which are 1ms
              
               while ( GPIO.B1 == 1 )       // wait for start from gun trigger
               {
               }
              
              TMR0 = RELOAD_VALUE;
              INTCON.T0IE = 1;   //enable tmr0 overflow ints
              INTCON.T0IF = 0;   //clear tmr0 int just in case
              INTCON.GIE = 1;    //and enable interrrupts.
              
               while( GPIO.B0 == 1 )  //keep generating pulses until we reach the set count of ms in the 3 4017 decade counters
               {
               if ( counter ) //got an interrupt?
               {
               GPIO.b2 = 1;	//yup, set output bit
               counter = 0;
               }
               delay_us( 100 ); //wait 100us
               GPIO.b2 = 0;		//clear output bit
              // delay_ms( 1 );
               
               };
               
               while ( 1 );	//all done, just sit here until reset.
              
               /*{
               if ( counter )
               {
               GPIO.b1 = 1;
               counter = 0;
               }
               delay_us( 100 );
               GPIO.b1 = 0;
              // delay_ms( 1 );
              
               };; //all done.*/
              
              }
              The comments in magenta were added once I'd figured out WTF it was doing.

              The frightening thing is that all it does is wait for a trigger, then generates 1ms pulses which are counted in an external counter.

              I used a PIC12F629 coz it was easier to get 1ms out of that than to use a divider chain.
              Last edited by zeitghost; 20 January 2016, 08:52.

              Comment


                Originally posted by NickFitz View Post
                I had the rest of the scouse for my tea. Very filling

                Today having been quite productive, I may try for a comparatively early night, and see if I can manage the same tomorrow. Not yet though
                That was about the time I intended going to bed, but was foiled by the inevitable Windoze(tm) updates.

                Comment


                  Morning all.


                  Skiing tomorrow
                  …Maybe we ain’t that young anymore

                  Comment


                    Morning though it feels later.

                    Went on a short run earlier and was too hot.

                    I only added gloves to my winter running outfit of long sleeve wicking top, hi viz jacket and tights. Not sure why other people need to wear hats as well.
                    "You’re just a bad memory who doesn’t know when to go away" JR

                    Comment


                      Morning

                      Comment

                      Working...
                      X