Jump to content

GordonS

EstablishedMember
  • Content Count

    11
  • Joined

  • Last visited

Community Reputation

0 Neutral

About GordonS

  • Rank
    Newbrie
  1. An oddity I note in that data is that the 0xCFF9 appears at 0x4200 but, if the 4200 gets divided by two to get the reall addres, then one half of that number goes to address 0x4100.5, which clearly isn't going to happen. Are you able to explain what _does_ happen? Thanks Gordon.
  2. Reinstalled V6.55, working. Ignoriung V6.60 for now.
  3. I've been trying to track down what's happening here, but it seems that V6.60 boostc.pic18.exe will not run properly on my machine from the build or compile buttons, or from the command line. I've reinstalled several times, rebooted once. Nothing. Odd. One other odd symptom that might give a clue. At one point the various build/compile buttons all became greyed out and the only way I could find to get them back was to reinstall.
  4. Hmmm Actually there's something much more fundamental going on here. Even if I exclude _all_ the code using a #if 0, the problem persists. Right now I can't compile at all. Win2K SP4
  5. Hi Guys, I'm seeing a similar crash, though not from struct pointers. The error pop-up reads: And the return error code in SourceBoost is 128 The command line is: The main application is fairly small (around 300 lines), but it includes a very-slightly-patched version of rs232_driver.h. I was going to offer to mail it, but at that size it might as well get attached here.. This code compiled fine in V6.55 in the IDE but I just had a warning/error from MPLAB that my compiler license "has expired" (? .. no it hasn't .. and SourceBoost is OK). I downloaded V6.60 in case this was a fixed bug, but just get this bug instead (or possibly as well?). This program is a cut-down of a larger program, so there may be a few redundant bits still lying around. --------8<----- LED_Head.h -------------------------------------------- #ifndef _LED_HEAD_H_ #define _LED_HEAD_H_ //================================================================== // USART definitions //================================================================== // // I think these must be values, not #defines from the CPU header file? // ( see serial_test.c in the Samples directory) // // #define USART_SIM #ifdef USART_SIM # define TX_PORT 0x0f8b # define TX_TRIS 0x0f94 # define TX_BIT 6 # define RX_PORT 0x0f82 # define RX_TRIS 0x0f94 # define RX_BIT 7 # define e_SPBRG 0x47 # define e_RCREG 0x48 # define e_TXREG 0x49 # define e_TXSTA 0x4A # define e_RCSTA 0x4B # define e_TXIF_PIR 0x4C # define e_RCIF_PIR 0x4C # define e_TXIF_BIT 4 # define e_RCIF_BIT 5 # define MODE (USART_reset_wdt) #else # define TX_PORT 0x0f82 # define TX_TRIS 0x0f94 # define TX_BIT 6 # define RX_PORT 0x0f82 # define RX_TRIS 0x0f94 # define RX_BIT 7 # define e_SPBRG 0xfaf # define e_RCREG 0xfae # define e_TXREG 0xfad # define e_TXSTA 0xfac # define e_RCSTA 0xfab # define e_TXIF_PIR 0xf9e # define e_RCIF_PIR 0xf9e # define e_TXIF_BIT 4 # define e_RCIF_BIT 5 # define MODE (USART_reset_wdt | USART_HW) #endif //#define bit_time 87 /* 115200 bps */ #define bit_time 174 /* 57600 bps */ //#define bit_time 340 /* 28800 bps */ //#define bit_time 690 /* 14400 bps */ //#define bit_time 520 /* 19200 bps */ //#define bit_time 1042 /* 9600 bps */ enum RX_STATE { RX_START, RX_CHAR1, // R, S, V, X, Y RX_CHAR2, // Looking for RR, Sxx, VV, XX, YO! RX_CHAR3, // Looking for Sxx RX_AWAITCR, // just await a <CR> (usually error recovery) RX_MAX_STATE // Something's awry -- try a reinitialise. }; enum ERRORS { ERR_OK, ERR_BAD_CHAR, ERR_BAD_CHAR1, ERR_BAD_CHAR2, ERR_BAD_CHAR3, ERR_BAD_DIGIT, }; #endif //_LED_HEAD_H_ --------8<---- LED_Head.c ---------------------------------- #include <system.h> #include "LED_Head.h" #include "rs232_driver.h" /* local copy -- adapt to buffered IRQ */ #define stroke_watchdog() clear_wdt() // //================================================================== // COOLLED Microscopy Illuminator LED Head controller //================================================================== // // $Header$ // // Uses serial data to communicate with main controller. // (Serial interface is 0V..+3V `TTL') // Uses parallel interface to read LED module IDs // Uses parallel interface to control LED switches // // Comms: // YO! interlock. Just echo the same string // RR Read LH/RH ident lines, responding R<LH><RH>\n // where LH and RN are 0x30..0x3F // S<SW> Set switch outputs, where <SW> is 0x30..0x7F // so can control 6 lines (we use only four for now) // Response SS\n // VV Return ident string // XX Reset the CPU (loop until watchdog). // No response. //Set clock frequency #pragma CLOCK_FREQ 8000000 //#define T0TIME 55 /* 100us ticks at 8MHz clock */ #define T0TIME 131 /* 1ms ticks at 8MHz clock, prescaler=16 */ enum ERRORS Error; char tick; // IRQ flag char tick_100us; char tick_1ms; char tick_10ms; char tick_100ms; char tick_1s; char char1; char char2; char char3; // Circular buffer for RX data (holds up to 63 chars). #define RX_BUF_MASK 0x3F // must match buffer size char RX_buffer[64]; // somewhere to hold incomming data char RX_fillidx; // .. where we're filling char RX_readidx; // .. where we're unfilling enum RX_STATE RX_state; // what were doing right now. char TX_buffer[8]; // small buffer for transmissions. char tracebuf[256]; char tracebuf_idx; void Head_error( enum ERRORS e ) { if( e ) { Error = e; } else { Error = ERR_OK; } } char Bad_char; char RX_status; void Head_error_irq( enum ERRORS e ) { if( e ) { Error = e; } else { Error = ERR_OK; } } // // Low overhead ascii/int encoding // // 0..4F --> '0'..0x7F // #define a2n( c ) ((c >= '0') ? c-'0' : -1) #define n2a( n ) ((n <= 0x4F) ? n+'0' : -1) //Timer 0 handler static void tick( void ) { tick++; // Urgent work only here, remainder in background. } void put_RX_buf( char c ) { char temp = RX_fillidx; temp += 1; temp &= RX_BUF_MASK; // Wrap buffer!! if( temp != RX_readidx ) { RX_buffer[RX_fillidx] = c; RX_fillidx = temp; } } char get_RX_buf( void ) { char temp; if( RX_fillidx != RX_readidx ) { pie1 &= ~0x20; // RX interrupts Off temp = RX_buffer[ RX_readidx ]; RX_readidx = (RX_readidx+1)&RX_BUF_MASK; // Wrap buffer!! pie1 |= 0x20; // RX interrupts On return( temp ); } else { return( '\0' ); } } static void RX_handler( char c ) { //tracebuf[tracebuf_idx] = c; put_RX_buf( c ); //tracebuf_idx++; } char RX_temp; // use to assemble hex-digit pairs. static void comms_RX( char c ) { char temp; switch( RX_state ) { case RX_START: // uart_init( 1, 8 ); // 57.6kbps at 8MHz // RX_state = RX_CHAR1; // break; case RX_CHAR1: char1 = c; if( 'Y' == c ) { RX_state = RX_CHAR2; } else if( 'R' == c ) { // Read head data RX_state = RX_CHAR2; // await a second R } else if( 'S' == c ) { // Set head outputs RX_state = RX_CHAR2; // await some data } else if( 'V' == c ) { RX_state = RX_CHAR2; // await a second V } else if( 'X' == c ) { // could be a reset... RX_state = RX_CHAR2; // await a 2nd X } else { RX_state = RX_AWAITCR; // Error .. await <CR> Head_error( ERR_BAD_CHAR1 ); } break; case RX_CHAR2: if( 'Y' == char1 ) { if( 'O' == c ) // "saw YO!" { puts( "YO!\n" ); // acknowledge it } RX_state = RX_AWAITCR; // Error .. await <CR> } else if( 'R' == char1 ) { // Read head data if( 'R' == c ) // RR .. send data { TX_buffer[0] = 'R'; TX_buffer[1] = n2a( portc & 0x0F ); // LH ident (six bits available, only four used) TX_buffer[2] = n2a( porta & 0x0F ); // RH ident (six bits available, only four used) TX_buffer[3] = '\n'; // send data } else { RX_state = RX_AWAITCR; // Error .. await <CR> Head_error( ERR_BAD_CHAR2 ); } RX_state = RX_AWAITCR; } else if( 'S' == char1 ) { // set head outputs char2 = a2n(c); if( char2 >= 0 ) { temp = portb; // update six bits without glitches. temp &= 0xC0; temp |= char2; portb = temp; puts( "SS\n" ); } else { RX_state = RX_AWAITCR; // Error .. await <CR> Head_error( ERR_BAD_CHAR2 ); } } else if( 'V' == char1 ) { if( 'V' == c ) // VV .. send version { puts( "VER=$Name$\n" ); } else { RX_state = RX_AWAITCR; // Error .. await <CR> Head_error( ERR_BAD_CHAR2 ); } RX_state = RX_AWAITCR; } else if( 'X' == char1 ) { // XX .. Reset while(1) { } // wait here for watchdog reset. RX_state = RX_AWAITCR; // Error .. await <CR> Head_error( ERR_BAD_CHAR2 ); } break; case RX_AWAITCR: if( '\r' == c ) { RX_state = RX_CHAR1; } break; default: // invalid state .. RX_START RX_state = RX_START; break; } } static void TX_handler( void ) { // Probably do this by polling. // we only send 3..5 characters at a time at present... } void interrupt( void ) { char mychar; //Handle RX interrupt if( pir1 & (1<<RCIF) ) { mychar = rcreg; if( mychar & 0x80 ) { RX_status = rcsta; Bad_char = mychar; Head_error_irq( ERR_BAD_CHAR ); RX_state = RX_AWAITCR; // Error .. await <CR> } else { RX_handler( mychar ); // call serial receive handler } // this is cleared by the read. // clear_bit( pir1, RCIF ); // clear RX interrupt bit } //Handle timer0 interrupt if( intcon & (1<<T0IF) ) { // tick(); // call timer 0 handler tick++; clear_bit( intcon, T0IF ); // clear timer 0 interrupt bit tmr0l = T0TIME; // 100us ticks } //Handle TX interrupt if( pir1 & (1<<TXIF) ) { // TX_handler(); //call serial transmit handler clear_bit( pir1, TXIF ); // clear TX interrupt bit } } void main() { char c; osccon = 0x73; // 8MHz, internal system clock. //Configure port A trisa = 0x0F; // LH array ident inputs //Configure port B trisb = 0x00; // outputs and ICD port //Configure port C trisc = 0xCF; // RH array ident inputs & serial comms //Initialize port A porta = 0x00; adcon1 = 0x0F; cmcon = 0x07; //Initialize port B //portb = 0x00; //Initialize port C portc = 0x00; t0con = 0xC3; tmr0l = T0TIME; // initialise some data tick = 0; tick_100us = 0; tick_1ms = 0; tick_10ms = 0; tick_100ms = 0; tick_1s = 0; RX_fillidx = 0; RX_readidx = 0; RX_state = RX_START; uart_init( 1, 8 ); // 57.6kbps at 8MHz //Enable interrupts (Peripherals and Timer0) pie1 = 0x20; // RX interrupts intcon = 0xE0; // Global, peripheral and timer0 IRQs. intcon2 = 0x84; // T0 high priority //Endless loop while( 1 ) { if( tick ) { tick = 0; tick_1ms++; } while( c = get_RX_buf() ) { comms_RX( c ); } if( tick_1ms >= 10 ) // 1ms ticks { tick_1ms -= 10; tick_10ms++; stroke_watchdog(); } } } --------8<------ Patches to rs232_driver.h --------- Line 371: //delay_us(1); Line 467: //putc(0x0a); // only send <CR>, not <LF> --------8<----------------------------------------------
  6. You are quite correct, on most devices RA4 is a sinking only port, but on the 16F676 it is a push pull. I'll add this one to the list to be fixed in the simulator. Regards Dave <{POST_SNAPBACK}> Am I right in thinking that this problem is still extant in V6.55? G.
  7. Oh Sugar .. I guess this is the problem: # A/D converter - Only 16F877A and compatible devices supported.
  8. Just for the record, I've just made an update to this project and the ADC function still does not work in the simulator on SourceBoost (now the V6.55 release candidate). FWIW, another project I'm working on right now uses the PIC12F683 .. and again the ADC doesn't work in the simulator. In both cases it works in MPLAM. The 16F676 version works in real hardware; I haven't yet put the 12F683 version into real hardware.
  9. Brain not in gear, sorry... This is PicAntIDE 5.2.3 (though the "about" box still says 5.2.2?) and the target is 16F877A. Gordon.
  10. Hi, I'm really not sure if this is a bug, a pending feature, or just "over to the user", but the Wizard generates a number function templates etc. for I2C, but no code. I wondered if these were templates to match some of the examples, but as they're not, I guess this may be an oversight. Best regards, Gordon Scott.
  11. Hi, The wizard's great, though I'm sure there are still lots of things one could do to improve it. A couple of thoughts I had whilst trialling PicAntIDE, were that the Wizard doesn't keep previous setups and this would be very useful as both a reminder of "what I did" and a base to evolve from. It also occurred to me as I created my own spreadsheet "PIC Resource Allocation Sheet", that this also would be a really handy addition to the Wizards features. Text, CSV, .ini or similar would seem fine to me. This could also be used as the template file. My spreadsheet has the pin-functions in columns with the pin number for various chips and the purpose to which I put it. This helps a lot to avoid conflicts with ICD/ICSP ports, I2C ports, UART Ports and so on. Best regards, Gordon Scott.
×
×
  • Create New...