pic program crashing


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    i ented a couple of lines to try to debug the problem...

    Here is the startup sequence...

    Code:
    include "bs1defs.bas"
    Define  CONF_WORD = 	0x3F3A
    Define  OSC				24				' Set clock speed
    DEFINE  SER2_BITS		8				' Ser2 number of data bits
    SEROUT2 PORTD.0,16468,["INITIALISING",10,13]
    Define  ADC_BITS        10     			' Set number of bits in result
    Define  ADC_SAMPLEUS    10    			' Set sampling time in uS
    ADCON0.7 = 0							' ADC clock set to Fosc/2
    ADCON0.6 = 0							' ADC clock set to Fosc/2
    ADCON1.6 = 0							' ADC clock set to Fosc/2
    
    INTCON = 0								' Disable all interupts
    'RCSTA = %10010000						' Enable serial port and continuous receive
    'TXSTA = %00100100						' Enable transmit and asynchronous mode with BRGH 1
    'SPBRG = 20								' Set baud rate to 57600 with 20mhz clock (BRGH = 1)
    ADT1 var word							' Create ADT1 to store curent ad conversion for AD channel 0
    ADT1MAX var word						' Create ADT1MAX to store curent ADC0 max val
    ADT1MAX = 0
    ADT1VAL var word
    ADT1VAL = 0
    ADV1 var word
    VOLT1H var word
    VOLT1L var word
    C1N	var bit
    C1N = 0
    C1S	var bit
    C1S = 0
    PCOUNTER var byte
    PCOUNTER = 0
    PTICK var bit
    PTICK = 0
    RPM var word
    RPM = 0
    TMR1_VAL var word
    TMR1_VAL = 0
    
    TRISE = 255							' Set PortE to all inputs
    TRISD = 0							' Set PortD to all outputs
    TRISC = 0							' Set PortC to all outputs
    TRISB = 0							' Set PortB to all outputs
    TRISA = 255 						' Set PORTA to all input
    ADCON1 = 0 							' PORTA is analog
    
    PIE1.0 = 0							' Disable TMR1 interupt (double check)
    T1CON.5 = 1 						' Setup TMR1 timings
    T1CON.4 = 1
    T1CON.3 = 1
    T1CON.1 = 0
    T1CON.0 = 1
    
    PORTB = 0
    PORTC = 0
    PORTD = 0
    SEROUT2 PORTD.0,16468,["INITIALISED",10,13]
    And on the PC I get "INITIALISING" and nothing else...
    So somewhere between INITIALISING and INITIALISED things go wrong...

  2. #2


    Did you find this post helpful? Yes | No

    Default

    right, i've placed serout2's after every single initialisation line and i discoverd something REALLY confusing...

    The serout2's stopped after this line...

    Code:
    TRISE = 255
    Why on earth would a TRISE operation affect serout2 command on PORTD?

    To prove it, i commented out the TRISE command and everything works perfectly...

    so, why does the TRISE cause a problem with SEROUT2

  3. #3


    Did you find this post helpful? Yes | No

    Default

    and then, when i open the datasheet for the 16f877a and search for trise i find this....

    SUMMARY OF REGISTERS ASSOCIATED WITH PORTD
    89h TRISE IBF OBF IBOV PSPMODE — PORTE Data Direction Bits
    Well, thats helpfull!

    TRISE affects PORTD!

    That is another for the FAQ's

    Thanks for everyones help

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. vb6 to program PIC
    By redpeak in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2009, 23:25
  3. Reading Program back from PIC
    By schlaray in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th May 2007, 14:23
  4. Which pic has a big flash program memory?
    By amindzo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st November 2006, 19:35
  5. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts