Jump to content

Malcolm White

EstablishedMember
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Malcolm White

  • Rank
    Newbrie
  • Birthday 04/12/1974

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Gender
    Male
  • Location
    Australia
  1. Ok.. I persisted (against sounder judgement), and I actually figured it out. This is what I ended up with, and modified it slightly to allow for the target "clock" to be supplied. typedef struct { unsigned char SECONDS; unsigned char MINUTES; unsigned char HOURS; } clock_t; clock_t CLOCK; void Clock_Next_Field(void); void Clock_Inc_Value(void); void Clock_59X_Rollover(void); void Clock_23H_Rollover(void); void Clock_Tick(clock_t &clockAddr) { asm { MOVLW _clockAddr MOVWF _fsr CALL Clock_Inc_Value CALL Clock_59X_Rollover CALL Clock_Next_Field CALL Clock_59X_Rollover CALL Clock_Next_Field CALL Clock_59X_Rollover CALL Clock_23H_Rollover } } void Clock_Next_Field(void) { asm { incf _fsr, F btfsc _status, C } Clock_Inc_Value(); } void Clock_Inc_Value(void) { asm { incf _indf, F } } void Clock_59X_Rollover(void) { asm { movlw 06h addwf _indf, F btfss _status, DC subwf _indf, F movlw A0h } Clock_23H_Rollover(); } void Clock_23H_Rollover(void) { asm { addwf _indf, W btfsc _status, C clrf _indf retlw DCh } } Seems to work with the test values... So.. Hoorah
  2. Take a look here... Roman Black's ZEZJ timer routines Down the bottom I think has something that will do.
  3. I thought that. That main concern was the application I want to use it in runs on two timer interrupts - one not that fast (about once a second), the other at about 15K/sec. So was trying to keep it small and fast. Rewriting it in C will increase both of these. I'll give it a go and see how it turns out.
  4. I don't know if this has been raised before, but a RS232 plugin would be nice - some way to either watch and/or interact with the serial port (physical or virtual. Maybe some way to pause the debug process to allow characters or data be sent or interacted with?
  5. Stored hours, minutes and seconds, with the rollover for 60 seconds, and 60 minutes, and 24 hours handled. Andrews page is here with the original source I thought of a way maybe to do it driving to work... (Probably not the smartest thing, but meh) void TICK(void) { asm { MOVLW SECONDS MOVWF FSR CALL SUB1 CALL SUB0 CALL SUB0 GOTO SUB2 } } void SUB0(void) { asm { INCF FSR SKPNC } SUB1(); } void SUB1(void) { asm { INCF INDF MOVLW 6 ADDWF INDF SKPDC SUBWF INDF MOVLW 0100H - 060H } SUB2(); } unsigned char SUB2(void) { asm { ADDWF INDF,W SKPNC CLRF INDF RETLW 0100H - 024H } } The only hiccup I see with it is the SKPNC in SUB0.
  6. I was going over a piece of assembler code (I admit, not written by me, but Andrew Warren with help from Scott Dattalo) that is a BCD clock. I liked the size of the code and simplicity. So I figured I would try and port it into C (using inline ASM), and found to my dismay that I couldn't due to the optimised nature of the code. SECONDS EQU [any register, on any page] MINUTES EQU SECONDS+1 HOURS EQU MINUTES+1 TICK: MOVLW SECONDS MOVWF FSR CALL SUB1 CALL SUB0 CALL SUB0 GOTO SUB2 SUB0: INCF FSR SKPNC SUB1: INCF INDF MOVLW 6 ADDWF INDF SKPDC SUBWF INDF MOVLW 0100H - 060H SUB2: ADDWF INDF,W SKPNC CLRF INDF RETLW 0100H - 024H After throwing that in, and figuring out how to get the equivalent command for the equate pointing to where my data was, I started getting errors in the CALL part of of the code. I trolled through the forums, I found out that to do the call you pull them out and put them into void fnName(void) calls. But as soon as I did this, I lost the flow of the code as I couldn't enter and exit where it needed to. Is there a way to port that, or something that complicate would need to be rewritten (and in turn losing the compactness of the code)? Or is there a way to compile it, and then link it into a library?
  7. Did this ever get posted? I only ask because I am looking for the same. I have found one site with the code in ASM, but it doesn't handle the jitter too well.
  8. Has any one else had an issue with upgrading to 5.0.7 and trying to use the logic analyser and led segment plugins. There is an error message that comes up mentioning they are using the wrong API. Is there a newer version of these somewhere?
  9. I have noticed this issue too. It's not only excessive switching, theres also gotos not needed as well in some cases. I tried writing an optimisation script, but that seems to not want to work either. The source code looks like this... ;;;;;;;; if(!(pir1&(1<<0x0005))) return; // If bit set, we can go bcf STATUS, RP0 bcf STATUS, RP1 btfsc _pir1, D'5' goto label_0004 return ;;;;;;;; ;;;;;;;; if((rcsta&(1<<0x0001))) { // If there is an overrun error label_0004 bcf STATUS, RP0 bcf STATUS, RP1 ...so I wrote the following script //////////////////////////////////////////// // Bit Test Jump Optimisation #1 //////////////////////////////////////////// Name: "Bit Test Jump Optimization #1" Debug: on Pattern: 00. btfsc %v0%, %v1% 01. goto %v2% 02. return 03.%v2% Action: change 00 "\tbtfss %v0%, %v1%" delete 01 delete 03 But it doesn't seem to work. If anyone knows how it can be recoded so it doesn't do this, or how to get the optimisation script working, it would be greatly appreciated. With four or five of these in a row, there is a 3 lines that could be removed each time... 15 lines doesn't sound like much, but the more efficient the better, right? ???
  10. I have been using the compiler for the last couple of weeks and have one tiny nagging issue. In the Watch section, when you right click an option you have Bin, Oct, Hex, Dec. What would be nice is something like "String". If you have declared an array, or such, it would be nice to be able to see what is in that array/string, instead of the first two bytes only. This would be handy in things like circular buffers. Also struct would be another one that would be nice to be able to see - what elements have which values in a struct definition.
  11. I've realised you can't do it (works out to be about 8 clock cycles per interrupt.) Oh well.
  12. I am having some difficulty in trying to set up Timer1 on a PIC16C63A... I am trying to get Timer1 to interrupt exactly 115200 times per second using a 3.6864Mhz crystal... It doesn't matter which values I put in the Timer1 prescaler and counter I cannot get it to do it exactely... Can anyone please suggest a formula I can use, or such to work out the correct values...
×
×
  • Create New...