Skip to content

Commit

Permalink
char out?
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed May 31, 2014
1 parent dea8958 commit 65eff05
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion serial/env.conf
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ end

echo stimulus created

attach analog_node porta3 t_wave
attach analog_node porta2 t_wave


# End.
52 changes: 27 additions & 25 deletions serial/send-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static __code uint16_t __at (0x2007) config = _XT_OSC & _PWRTE_ON & _BODEN_ON

// If KHZ is not specified by the makefile, assume it to be 4 MHZ
#ifndef KHZ
#define KHZ 8000
#define KHZ 4000
#endif

// These are fixed. The 16f876 can only use these as transmit and recieve.
Expand Down Expand Up @@ -38,6 +38,7 @@ static const char str[]={'d', 'a', 't', 'a', '\n', '\0'};
void main(void)
{
static unsigned char i;
static char tx;
TRISB = 0X00;
PORTB = 0X00;
TRISC|=TX_BIT|RX_BIT; // These need to be 1 for USART to work
Expand All @@ -49,8 +50,8 @@ void main(void)
TXEN=1; // Enable transmission mode


//while(1) // repeat over and over
//{
while(1) // repeat over and over
{
PORTB = 0X01; // message flag on
for(i=0; str[i] != '\0'; i++)
{
Expand All @@ -59,30 +60,31 @@ void main(void)
while(!TXIF); // Wait while the output buffer is full
PORTB = 0X01; // char flag off
}
ADCON1=0b00100010; //adc initonce



TMR2=0x00; //clear timer2 output

T2CON=0x04; //start timer2

TRISA=0x0C; //set AN2 (RAx) and AN3 (RAx) to inputs

ADCON0=0b11010101; //begin AD conversion on AN2

while(ADCON0<2>=1) //wait until ADCON0<1> flips to 0

continue;

//PORTB=ADRESH; //write ADC result to portB
TXREG=ADRESH; // Add a character to the output buffer
ADCON1=0b00100010; //adc initonce
TMR2=0x00; //clear timer2 output
T2CON=0x04; //start timer2
TRISA=0x0C; //set AN2 (RAx) and AN3 (RAx) to inputs
ADCON0=0b11010101; //begin AD conversion on AN2
while(ADCON0<2>=1); //wait until ADCON0<1> flips to 0
//continue;
tx=(ADRESH/100)+0x30; // Add a character to the output buffer
TXREG=tx;
while(!TXIF); // Wait while the output buffer is full
tx=((ADRESH/10) & 0x0F)+0x30; // Add a character to the output buffer
` if (tx>=10) tx=tx-9;
TXREG=tx;
while(!TXIF); // Wait while the output buffer is full
tx=((ADRESH) & 0x0F)+0x30; // Add a character to the output buffer
` if (tx>=10) tx=tx-9;
TXREG=tx;
while(!TXIF); // Wait while the output buffer is full
TXREG='\n'; // Add a character to the output buffer
while(!TXIF); // Wait while the output buffer is full
T2CON=0x00; //end timer

T2CON=0x00; //end timer

PORTC=TMR2; //write timer result to portC


PORTB = 0X00; // message flag on
//}
}

}
6 changes: 0 additions & 6 deletions serial/sim.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
rem sdcc -V --use-non-free --debug -mpic14 -p16f876 int-serial.c

rem gpsim -pp16f876 -s int-serial.cod int-serial.asm

gpsim -c env.conf -s send-data.cod

rem gpsim -pp16f876 -s 3-uart_tx.cod -c suart.stc > scope.ch0 = "portc6"

cmd

0 comments on commit 65eff05

Please sign in to comment.