Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by ric

  1. That document was specifically for PIC16F87x chips. The exact same bit in the PIC16F877/A datasheets is just named "DEBUG".
  2. The PIC16F87X debug hardware is documented. http://ww1.microchip.com/downloads/en/devicedoc/51242a.pdf Unfortunately the newer chips aren't, but they are probably just extending the same concept.
  3. Was any solution found? I note the CONFIG bits have not been shown. The chip will not run if the oscillator has not been set up correctly, and it will be rapidly resetting if the WDT has not been disabled.
  4. Of course, the simulator may be fine. It may just be Harmony that's not implementing USART via DMA correctly...
  5. Comes from https://www.microchip.com/forums/m1090367.aspx George is on the case. He thinks it should work, despite the "very helpful" support technician saying it wouldn't...
  6. Personally I'd just track it in putch(). Then you know there won't be any tricky way to bypass your check.
  7. You don't need to edit powerup.as if you tell the compiler about the " NVMREG" errata. https://www.microchip.com/forums/m969418.aspx
  8. We're still selling products using PIC16F877A, more than 18 years after I designed the first version. 🙂 (In the QFN-44 package though)
  9. ric

    Melbourne Weather

    Who rides a push-bike in that weather? 🌨️❄️⛷️
  10. ric

    Melbourne Weather

    We're expecting a month's worth of rain in a day tonight... https://www.theage.com.au/national/victoria/melbourne-weather-victoria-could-endure-month-s-worth-of-rain-in-a-single-day-20190205-p50vwe.html However, that's just because we're catching the fringe of the huge downpour up in Queensland. They've had a year's worth of rain in a week, over a metre of rain! https://www.theage.com.au/national/queensland/townsville-on-edge-as-dam-gates-open-20190203-p50vfp.html https://www.theage.com.au/environment/weather/how-queensland-is-being-soaked-by-an-unprecedented-monsoonal-burst-20190204-p50vib.html Their "flood mitigation" dam quickly filled up to 250% of nominal capacity before they had to fully open the floodgates, which quickly put two suburbs of Townsville under water.
  11. ric

    Melbourne Weather

    Should I mention that phpBB had this feature over ten years ago? 😉 Melbourne got to 39C today, and is heading towards 39 or more tomorrow. There's some major fires burning in the east of the state, and we've lost the use of two of the "Elvis" sky crane choppers after one of them crashed into a dam while taking on water a few days ago. (That one is still in the dam, and the second one has been grounded until they find out what happened to the first...) https://www.theage.com.au/national/victoria/total-fire-ban-declared-for-sunday-amid-fears-of-extreme-heat-20190202-p50vau.html https://www.theage.com.au/national/victoria/water-bombing-aircrane-lands-in-dam-while-fighting-fires-in-east-gippsland-20190128-p50u6s.html
  12. The "high gain antenna pointing routine" sounds just like the problems with the AE-35 antenna reported by HAL9000 in 2001! 😉 http://2001.wikia.com/wiki/AE-35_unit
  13. The User Guide for XC8 v2.0 still lists exactly the same options.
  14. XC8 has several different ways of implementing switch case. It analyses how many conditions there are, and what pattern they follow before deciding which one to use. When you read the LST file, it tells you which type it has decided to use.
  15. ric

    Melbourne Weather

    Melbourne's not too bad. Sydney has much worse humidity. We have an evaporative cooler on the house at home, and it works well on most days, except for the one or two really humid hot days.
  16. ric

    Melbourne Weather

    You're on. 😙 Friday in Melbourne got to 44C where I work, and 46 where my wife was at home. How's this for a cool change (which Melbourne is famous for)...
  17. Plus you have colleges still making their students use C18... https://www.microchip.com/forums/m1083909.aspx
  18. Or if you really want to do your head in, check out Whitespace The only active characters are space, tab, and LF. Everything else is treated as a comment.
  19. Agree 100% here, and am still flabbergasted that this oversight was not corrected when the enhanced PIC16F families were introduced.
  20. How to send an email via dial up modem, circa 1984...
  21. I just had a naughty thought. If you restrict usage to enhanced devices, presumably our routine is allowed to trash WREG, STATUS and BSR. What if we just used BSR as our temporary scratch register? It's a core register, so doesn't need banking to access (obviously!), and is automatically preserved when interrupts are serviced. The remaining four instructions are all immediate, so not affected by BSR. Edit: Scrub that. BSR is only 5 or 6 bits, never 8, so can't be used for our purpose which requires all 8 bits.
  22. Very nice. You're right about the bug though. I think I got conned by C99 mode with no optimisation. Normally the parameter is just in W, so you do need to create a temporary variable and save it as you did. Is your tmp variable essentially static? i.e. are other functions at the same level able to overlay that location? Now THIS sounds interesting. How would you do that? This function does not alter the scratch location, it just needs to be able to read it.
  23. That was what I did first, and was horrified by the code generated by XC8 2.0 in free mode. That was my attempt to force it to do it efficiently. XC8 v.1.34 in Pro mode only has one pointless instruction: 309 ;main.c: 41: return WREG; 310 07FE 0809 movf 9,w ;volatile 311 07FF 0008 return Std and Free mode have an extra pointless instruction: 320 07FD 0020 movlb 0 ; select bank0 321 07FE 0809 movf 9,w ;volatile 322 07FF 0008 return and XC8 2.0 in C90 Free mode (Opt 0) is a bit ordinary: 1218 07D4 ;main.c: 41: return WREG; 1219 movlb 0 ; select bank0 1220 07D4 0020 movf (9),w ;volatile 1221 07D5 0809 goto l9 1222 07D6 2FD7 1223 l594: 1224 07D7 line 42 1225 1226 l9: 1227 07D7 return C90 Free / Opt 1 is same as v1.x in free mode 541 ;main.c: 41: return WREG; 542 07D9 0020 movlb 0 ; select bank0 543 07DA 0809 movf 9,w ;volatile 544 07DB 0008 return C99 mode generated the same code. (And that macro generates horrible code if you are not in Pro mode...)
  24. A suggested C macro is almost as good, but adds an extra temporary storage location for the first calculation #define PARITY(b) ((((((b)^(((b)<<4)|((b)>>4)))+0x41)|0x7C)+2)&0x80) It also generates a "warning: (752) conversion to shorter data type" on the macro invocation.
  25. This is my attempt to convert the blazingly fast assembler routine for calculating parity into a C function. The original comes from here: https://www.microchip.com/forums/m4762.aspx Unfortunately Microchip have killed off the board where the original discussion took place at http://asp.microchip.com/webboard/wbpx.dll/~DevTools/read?21443,5 #include <xc.h> //returns 0x00 (even parity) or 0x80 (odd parity) unsigned char parity(volatile unsigned char dat) //("volatile" is required because no C code reads the parameter) { asm("swapf parity@dat,w"); //assume correct bank is still selected asm("xorwf parity@dat,w"); //W has 8 bits reduced to 4 with same parity asm("addlw 41h"); // bit 1 becomes B0^B1 and bit 7 becomes B6^B7 asm("iorlw 7Ch"); // for carry propagation from bit 1 to bit 7 asm("addlw 2"); // Done! the parity bit is bit 7 of W asm("andlw 80h"); // set NZ if odd parity, and leave 00 or 80 in W asm("return"); return 1; //dummy instruction to defeat "no return value" error } void main(void) { unsigned char idx=0; while(1) { PORTA = parity(idx); idx++; } } I'm not sure if there's a cleaner way to suppress the "no return value" error, without generating extra code.
  • Create New...