|
|
View previous topic :: View next topic |
Author |
Message |
Eeprom_programmer
Joined: 07 Aug 2007 Posts: 24
|
RS232 communication |
Posted: Mon Aug 13, 2007 7:37 am |
|
|
Hey,
Currently i am using a program on VB to turn on/0ff pins on a microcontroller.
Does anyone have an idee how to write this code in CCS?
Code: |
Main:
' Use the programming port to receive
' data at 2400 baud
' Wait for the synch byte (255) and then
' get the PinNumber and PinState
Serin 16,16780,[WAIT(255),PinNumber,PinState]
' If PinState=0 Then go to GoLow
' otherwise go to GoHigh
Branch PinState,[GoLow,GoHigh]
Goto Main
' Set The pin low
GoLow:
LOW PinNumber
Goto Main
' Set the pin high
GoHigh:
HIGH PinNumber
Goto Main
|
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Aug 13, 2007 8:09 am |
|
|
Code: | #include <18F458.h>
#fuses HS, NOWDT, PUT, NOLVP
#use delay(clock=16000000)
#use rs232 (baud=2400, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
void wait_pin_command()
{
int8 PinNumber;
int8 PinState;
while (getc() != 255)
; // wait for the synch byte
PinNumber = getc();
PinState = getc();
if (PinState == 0)
{
output_low(PinNumber);
}
else
{
output_high(PinNumber);
}
}
void main()
{
while (TRUE)
{
wait_pin_command();
}
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|