Skip to content

Commit

Permalink
binary data test 4Mhz clock
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed May 31, 2014
1 parent 4b9ccb4 commit dea8958
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 24 deletions.
36 changes: 31 additions & 5 deletions serial/env.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
# and load this file from it. Something like this:
# ----------- myproject.stc ---------------
# load s mycode.cod
frequency 8000000
# frequency 12000000
# load c netlist.stc
# -----------------------------------------
# You can then just load this new file:
# gpsim -c myproject.stc
# and use netlist.stc whenever you save from the breadboard.
#


# Set the Clock frequency to 4 Mhz.
frequency 4000000
# Processor position:
module library libgpsim_modules.dll

Expand All @@ -39,9 +39,35 @@ U1.ypos = 72


# Connections:
node n
attach n portc6 U1.RXPIN
node PIC_tx
node PIC_rx

attach PIC_tx portc6 U1.RXPIN
# attach PIC_rx portc7 U1.TXPIN
# Create a stimulus node:
node analog_node
attach analog_node porta3
# Create a triangle wave stimulus that's 1000 cycles long
# and attach it to porta bit 0. The duty cycle is 30%
# and the phase is 10%.
echo stimulus create

stimulus tri

period 1000

high_time 300

phase 100

#port porta 0
name t_wave

end

echo stimulus created

attach analog_node porta3 t_wave


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


// Until SDCC supports strings again the message will be far more terse.
static const char str[]={'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '\r', '\n', '\0'};
static const char str[]={'d', 'a', 't', 'a', '\n', '\0'};

void main(void)
{
Expand All @@ -49,22 +49,40 @@ void main(void)
TXEN=1; // Enable transmission mode


while(1) // repeat over and over
{
PORTB = 0X01; // message flag on
for(i=0; str[i] != '\0'; i++)
{
PORTB = 0X03; // char flag on

TXREG=str[i]; // Add a character to the output buffer

while(!TXIF); // Wait while the output buffer is full

PORTB = 0X01; // char flag off
}
PORTB = 0X00; // message flag on

}


//while(1) // repeat over and over
//{
PORTB = 0X01; // message flag on
for(i=0; str[i] != '\0'; i++)
{
PORTB = 0X03; // char flag on
TXREG=str[i]; // Add a character to the output buffer
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
while(!TXIF); // Wait while the output buffer is full

T2CON=0x00; //end timer

PORTC=TMR2; //write timer result to portC

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

0 comments on commit dea8958

Please sign in to comment.