Oud 13-05-2003, 21:24
JBM
JBM is offline
Ik heb nu een goed werkend programmatje op een PIC16C877 staan dat RS232 signelan opvangt en daarop een reactie uitvoert. Het programmatje werkt perfect.

Nu wil het programmatje omvormen in iets bruikbaars op een PIC12C509A. Ik weet dat deze een andere opbouw heeft van poorten, en dit is nou helemaal het probleem.....
Ik heb geen flauw idee waarom er bepaalde dingen fout gaan....

De compiler meld mij dat de functie:" delay_s (1); " niet meer werkt. (oja, ik programeer het geheel in C)
Hij zegt dat de initsialisatie van poorten (het zeggen welke pin wat doet (input/output)) van geen kanten klopt.
En hij begint te zeuren dat " output_high_port_a (1); " niet meer werkt....

Ik ben de wanhoop nabij.....
Met citaat reageren
Advertentie
Oud 13-05-2003, 21:37
bam
Avatar van bam
bam is offline
enig source werk makkelijker voor sommige mensen

je kan de [code] tag gebruiken.
__________________
Ik ben nieuw
Met citaat reageren
Oud 14-05-2003, 10:40
JBM
JBM is offline
Code:
/**************************************************************
  Description:
  Author(s):
  History:
	
  Copyrights(C) 2003
***************************************************************/

//RS232 settings
#pragma RS232_TXPORT PORTA
#pragma RS232_RXPORT PORTA
#pragma RS232_TXPIN  4
#pragma RS232_RXPIN  0
#pragma RS232_BAUD 2400

//Timing settings
#pragma CLOCK_FREQ 20000000


//////////////////////////////////////////////
// Main program entry
//////////////////////////////////////////////

char code;

void print( const char* text )
{
    char i = 0;
    while( text[i] != 0 )
        putchar( text[i++] ); 
}

void shortburst()
{
    output_low_port_a (0);
    output_high_port_a (1);
    delay_ms(250);
    delay_ms(250);
    delay_ms(200);
    output_low_port_a (1);
    output_high_port_a (0);
}

void longburst()
{
	output_low_port_a (0);
	output_high_port_a (1);
	delay_s (1);
	delay_ms(250);
	delay_ms(250);
	output_low_port_a (1);
	output_high_port_a (0);
}


main()
{
	//Disable all interrupts
	disable_interrupt( GIE );   //disable interrupts

	//Init ports
	set_bit( STATUS, RP0 );
	//A, B port initialization
	PORTA = 11110111b;
 //   TRISB = 00000010b;	//All pins configured for output \\pin 1=input
    clear_bit( STATUS, RP0 );    
    
    output_high_port_a (0);    
    delay_s( '2' );
    print("Start programma\n\r");
    delay_s( '2' );
    
    while(1)
    {
        code = getchar();
       
        if (code == 'a'){shortburst(); print("Short burst\n\r");}
        if (code == 'w'){shortburst(); print("Short burst\n\r");}
        if (code == 's'){longburst(); print("Long burst\n\r");}
    }
}
Met citaat reageren
Oud 14-05-2003, 19:48
JBM
JBM is offline
Inmiddels ben ik al een heel eind verder, ik zal de code in een post hieronder zetten, maar ik zit mu met een ander probleem....

de processor start niet...... hij is niet dood, er loopt spanning doorheen, maar hij doet niks, alsof hij zegt: "Val dood, maar ik heb geen zin"... ik weet het niet meer....
__________________
KISS (Keep It Smart and Simple)
Met citaat reageren
Oud 14-05-2003, 19:50
JBM
JBM is offline
de code in C
Code:
/**************************************************************
  Description:
  Author(s):
  History:
	
  Copyrights(C) 2003
***************************************************************/

//RS232 settings
#pragma RS232_TXPORT GPIO
#pragma RS232_RXPORT GPIO
#pragma RS232_TXPIN  4
#pragma RS232_RXPIN  0
#pragma RS232_BAUD 2400

//Timing settings
#pragma CLOCK_FREQ 4000000


//////////////////////////////////////////////
// Main program entry
//////////////////////////////////////////////

char code;
char POORTJE@0x06;

void output_low() {
	asm {
		movlw	1
		bcf		GPIO,1
		tris	GPIO
	}	
}

void output_high() {
	asm {
		movlw   1
		bsf 	GPIO,1
		tris	GPIO
	}
}

void shortburst()
{
    output_high();
    delay_ms(250);
    delay_ms(250);
    delay_ms(200);
    output_low();
}

void longburst()
{
	
	output_high();
	delay_s (1);
	delay_ms(250);
	delay_ms(250);
	output_low();

}	

main()
{
	//Init ports
	asm {
		movlw	1
		tris	GPIO
	}
    
    output_high();    
    delay_s( '2' );
    output_low();
    
    while(1)
    {
        
        
        if(POORTJE && 00000001b)
		{
			delay_ms(1);
			if(POORTJE && 00000001b)
			{
				code = getchar();
				if (code == 'a')shortburst();
				if (code == 'w')shortburst();
				if (code == 's')longburst();
			}
		}
		
		
		
		/*
        ingang meten, 
        
        hoog -> even wachten in eerste 10%
        nogsteeds hoog -> code
        */
       

    }
}
de code in Assembler
Code:
; This file was generated by C2C-plus compiler version 5.0.5e

	include "p12C509A.inc"
	;Variables *****************************************
_C5X_tmp                        equ 0x07 ;1
param00_delay_ms                equ 0x08 ;2
param00_delay_s                 equ 0x0a ;1
_code                           equ 0x0b ;1
_rs232_delay_counter            equ 0x0c ;1
_counter__c2c_getchar           equ 0x0d ;1
_ret__c2c_getchar               equ 0x0e ;1
_POORTJE                        equ 0x06 ;1
	ORG 0
	movwf OSCCAL
	goto start__code
_output_low
	goto _output_low__code
_output_high
	goto _output_high__code
_shortburst
	goto _shortburst__code
_delay_ms
	goto _delay_ms__code
_longburst
	goto _longburst__code
_delay_s
	goto _delay_s__code
__c2c_getchar
	goto __c2c_getchar__code
__c2c_rs232_delay2
	goto __c2c_rs232_delay2__code
__c2c_rs232_delay
	goto __c2c_rs232_delay__code
start__code
_main__code
	movlw 1
	tris GPIO
	call _output_high
	movlw D'50'
	movwf param00_delay_s
	call _delay_s
	call _output_low
label_0003
	bcf FSR, 5
	movf _POORTJE, W
	andlw 0xFF
	btfsc STATUS, Z
	goto label_0006
	movlw 1
label_0006
	andlw D'255'
	btfsc STATUS, Z
	goto label_0003
	movlw D'1'
	movwf param00_delay_ms
	call _delay_ms
	bcf FSR, 5
	movf _POORTJE, W
	andlw 0xFF
	btfsc STATUS, Z
	goto label_0008
	movlw 1
label_0008
	andlw D'255'
	btfsc STATUS, Z
	goto label_0007
	call __c2c_getchar
	movf _C5X_tmp, W
	movwf _code
	movlw D'97'
	subwf _code, W
	btfss STATUS, Z
	goto label_0013
	call _shortburst
label_0013
	movlw D'119'
	subwf _code, W
	btfss STATUS, Z
	goto label_0014
	call _shortburst
label_0014
	movlw D'115'
	subwf _code, W
	btfss STATUS, Z
	goto label_0015
	call _longburst
label_0015
label_0007
label_0005
	goto label_0003
label_0004
_main__end
_output_low__code
	movlw 1
	bcf GPIO,1
	tris GPIO
	retlw 0
_output_low__end
_output_high__code
	movlw 1
	bsf GPIO,1
	tris GPIO
	retlw 0
_output_high__end
_shortburst__code
	call _output_high
	movlw D'250'
	movwf param00_delay_ms
	call _delay_ms
	movlw D'250'
	movwf param00_delay_ms
	call _delay_ms
	movlw D'200'
	movwf param00_delay_ms
	call _delay_ms
	call _output_low
	retlw 0
_shortburst__end
_delay_ms__code
label_0000
	movlw D'142'
	movwf param00_delay_ms+1
	nop
	nop
label_0001
	nop
	nop
	nop
	nop
	decfsz param00_delay_ms+1, F
	goto label_0001
	nop
	decfsz param00_delay_ms, F
	goto label_0000
	nop
	retlw 0
_delay_ms__end
_longburst__code
	call _output_high
	movlw D'1'
	movwf param00_delay_s
	call _delay_s
	movlw D'250'
	movwf param00_delay_ms
	call _delay_ms
	movlw D'250'
	movwf param00_delay_ms
	call _delay_ms
	call _output_low
	retlw 0
_longburst__end
_delay_s__code
label_0002
	movlw D'250'
	movwf param00_delay_ms
	call _delay_ms
	movlw D'250'
	movwf param00_delay_ms
	call _delay_ms
	movlw D'250'
	movwf param00_delay_ms
	call _delay_ms
	movlw D'250'
	movwf param00_delay_ms
	call _delay_ms
	decfsz param00_delay_s, F
	goto label_0002
	retlw 0
_delay_s__end
__c2c_getchar__code
	movlw D'8'
	movwf _counter__c2c_getchar
	clrf _ret__c2c_getchar
label_0009
	btfsc GPIO, 0
	goto label_0009
	call __c2c_rs232_delay2
	btfsc GPIO, 0
	goto label_0009
label_0011
	call __c2c_rs232_delay
	rrf _ret__c2c_getchar, F
	bcf _ret__c2c_getchar, 7
	btfsc GPIO, 0
	bsf _ret__c2c_getchar, 7
	decfsz _counter__c2c_getchar, F
	goto label_0011
	call __c2c_rs232_delay
	movf _ret__c2c_getchar, W
	movwf _C5X_tmp
	retlw 0
__c2c_getchar__end
__c2c_rs232_delay2__code
	movlw D'67'
	movwf _rs232_delay_counter
label_0010
	decfsz _rs232_delay_counter, F
	goto label_0010
	retlw 0
__c2c_rs232_delay2__end
__c2c_rs232_delay__code
	movlw D'134'
	movwf _rs232_delay_counter
label_0012
	decfsz _rs232_delay_counter, F
	goto label_0012
	retlw 0
__c2c_rs232_delay__end
	END
__________________
KISS (Keep It Smart and Simple)
Met citaat reageren
Advertentie
Reageren

Topictools Zoek in deze topic
Zoek in deze topic:

Geavanceerd zoeken

Regels voor berichten
Je mag geen nieuwe topics starten
Je mag niet reageren op berichten
Je mag geen bijlagen versturen
Je mag niet je berichten bewerken

BB code is Aan
Smileys zijn Aan
[IMG]-code is Aan
HTML-code is Uit

Spring naar


Alle tijden zijn GMT +1. Het is nu 06:54.