Jump to content

gordon@cil-uk.co.uk

EstablishedMember
  • Content Count

    32
  • Joined

  • Last visited

Community Reputation

0 Neutral

About gordon@cil-uk.co.uk

  • Rank
    Regular

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. One last curiosity. When I grafted this back itno the main project, I omitted to correct the ansel = ANS1 line, but the program still works and for Microchip's documentation, I think it should not have. Hmm.
  2. I appear to have a working A/D, though not without some notable problems. FYI, here's how it went..... I found one bug -- using a bit index as a value in ansel, however it still wouldn't work as there were some other problems. To cover all the possible timing/delay situations (too quick, too slow, various register settings) I set each part of adcon0 separately, with a fairly substantial delay between them. I doubt I need them all, or so long, but I don't have time right now to tune them or remove surplus delays. Despite using the slower of the recommended Tad setting (Fosc/16 on th
  3. It appears I can't do this: adcon0 = ADCH1|(1<<ADON)|(1<<GO); // AN1 and go. I have to wait a while before starting the conversion. ... which I now do, but still with no success
  4. It appears I can't do this: adcon0 = ADCH1|(1<<ADON)|(1<<GO); // AN1 and go. I have to wait a while before starting the conversion. ... which I now do, but still with no success
  5. Hi Guys, This has to be an error by me, but I can't presently see it. I'm trying to do a simple polled ADC on port RA1, but whatever I try, I get zero in adresh:adresl from both the simulator and real hardware. Here's a heavilly stripped down extract from the application: /******************************************************************** Filename: Try.c */ #include <system.h> //Target PIC16F676 configuration word #pragma DATA _CONFIG, _PWRTE_OFF & _WDT_ON & _CP_OFF & _INTRC_OSC_NOCLKOUT // _INTRC_OSC_NOCLK not valid?? //#pragma DATA _CONFIG, 0x3FF4 /
  6. I think I was mistaken about 2). I compiled but didn't link and looked at the .asm file, but I now think the .asm file wasn't rewritten. --------8<---------------------------- Running the 6.31 compiler from SourceBoost with either a combined or a separate eeprom.c file containing the eeprom code, I get good code. Running the same from MPLab, I continue to get bad code. (Irritatingly, I can't cut and paste the compile report.) Retyped significant bits from SourceBoost are (E&OE): "C:\Program Files\SourceBoost\boost.pic18.exe" -t PIC18F2420 Pod.c eeprom.c ......Ver
  7. Just tried a couple of other things: 1) Moved the eeprom code from it's separate source file into the main source file. The eeprom code is now virtually the first code in the main file (after a one-statement error trap). No change. 2) Then switched back from MPLab to the SourceBoost IDE in case it's IDE related. No change. I'm using a slightly older compiler version (6.30), though I see no reference to changes in this area. Maybe I should update anyway
  8. I have posted some more in that thread and will continue there rather than here, to avoid duplications.
  9. Curious! For compaerison and to hope it helps give a clue what's going on, here are the equivalent lines from my file. I've included the entire code block and marked the relevant bit. ORG 0x00000972 0972 eeprom_wri_00008 ; { eeprom_write; function begin 0972 label268437115 0972 0E02 MOVLW 0x02 0974 010F MOVLB 0x0F 0976 14A6 ANDWF gbl_eecon1, W 0978 E001 BZ label268437116 097A D7FB BRA label268437115 097C label268437116 097C 0102 MOVLB 0x02 097E 5106 MOVF eeprom_wri_00008_arg_address, W, 1 0980 010
  10. Sorry .. forgot vital information: Executing: "C:\Program Files\SourceBoost\boostc.pic18.exe" Pod.c -O0 -W1 -t 18F2420 BoostC Optimizing C Compiler Version 6.30 (for PIC18 architecture) http://www.picant.com/c2c/c.html Copyright(C) 2004-2006 Pavel Baranov Copyright(C) 2004-2006 David Hobday
  11. Hi Guys, This appears to be a conflict between BoostC's output and the PIC's "required sequence". Bug report posted. For completeness in this thread: PIC18F2420 (and I presume others in the series) demands: MOVLW 0x55 MOVWF _eecon2 MOVLW AAh MOVWF _eecon2 BSF _eecon1, WR but BoostC, even using the above code in an inline asm{} is generating: MOVLW 0x55 MOVLB 0x0F MOVWF gbl_eecon2 MOVLW 0xAA MOVLB 0x0F MOVWF gbl_eecon2 MOVLB 0x0F BSF gbl_eecon1,1 which apparently is not good enough as "the reason the WR bit cannot be set is because there is an interrupt
  12. Hi Guys, I've been chasing a "can't write EEPROM" problem that looks like is't a compiler/chip incompatibility. Microchip's "required sequence" to do the write is: MOVLW 0x55 MOVWF EECON2 MOVLW AAh MOVWF EECON2 BSF EECON, WR But BoostC seems to be generating: MOVLW 0x55 MOVLB 0x0F MOVWF gbl_eecon2 MOVLW 0xAA MOVLB 0x0F MOVWF gbl_eecon2 MOVLB 0x0F BSF gbl_eecon1,1 even with the "required sequence" written as an inline asm{} block. Microchip commented thus: --------8<-------------------------------------------------------------- Description: Unable to write i
  13. I was pretty sure I'd tried that, but tried it again to be sure. My closing lines are now: set_bit( eecon1, WR ); set_bit( intcon, GIE ); // enable interrupts while(eecon1 & (1<<WR) ); clear_bit( eecon1, WREN ); while(eecon1 & (1<<WRERR) ); } ... but the behaviour is the same. One thing I notice and that may _well_ be a clue, is that I don't actually see the WR flag set. I [allegedly] set it, but don't see it, which is somewhat suspicious. The datasheet says it's disabled during Tpwrt, but I understand that timer has to expire before the CPU
  14. Hi guys, I'm trying to write to the internal EEPROM of a PIC18F2420, but I don't seem to be able to get it to write. Everyhting I try leaves the data unchanged and has the WRERR flag set in eecon2. Here follows what I'm using, showing a couple of variations I've tried (thjough I've tried _many_ more). The code never (well, > 10 seconds) exits from the final while loop. Anyone see a deliberate error in here please? void eeprom_write(char address, char data) { // Pause here if still writing previous data // while(eecon1 & (1<<WR) ); // while(pir2 &a
×
×
  • Create New...