i try to receive a byte and process it, but it seems the Variable is empty/undefiend/whatever. (pin 12 [R1out] of a max232 hooked up to pin 18 [RA1] of a PIC16F84)
for a test, i write the received byte into the PICs eprom and flash a LED hooked up to PORTB.0
settings in my terminal tool are 2400 baud, no parity, 8 data bits, 1 stop bit, no hardware flow control
#define RecAHigh set PORTA.1 ON
#define RecALow set PORTA.1 OFF
InitSer (1, r2400, 1+WaitForStart, 8, 1, none, normal)
main:
SerReceive (1, Temp)
EpWrite (1, Temp )
EpWrite (2, Temp )
EpWrite (3, Temp )
EpWrite (4, 0X40 ) 'as a reference if anything is written at all....
poke 6, 1
wait 50 10ms
poke 6, 0
goto main
if i send e.g. a blank i see the LED flashing.
after that i'd expected "20" at address 1, 2 and 3 in the eprom memory of the PIC. but when i read it out i have FF, FF, FF, 40
...sorry if this has been asked already... i spent a while trying to find a 'search' function for this forum but was not able to find anything.
thanks
daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
From memory, the MAX232 inverts the signal. Try changing the last parameter of InitSer from normal to invert, and see if that helps.
There are also a couple of minor things in the program that you'll need to change:
- Remove the "set" from the constants for RecAHigh/Low. This is an easy mistake to make, I've done it several times included in a help file (now fixed).
- Add something to set the directions of the pins. These 2 lines should do this:
Dir PORTA.1 in
Dir PORTB out
Also, you can just use "PORTB = 1" or "PORTB = 0" in GCBASIC, no need for the poke unless that's what you prefer.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i try to receive a byte and process it, but it seems the Variable is empty/undefiend/whatever. (pin 12 [R1out] of a max232 hooked up to pin 18 [RA1] of a PIC16F84)
for a test, i write the received byte into the PICs eprom and flash a LED hooked up to PORTB.0
settings in my terminal tool are 2400 baud, no parity, 8 data bits, 1 stop bit, no hardware flow control
#define RecAHigh set PORTA.1 ON
#define RecALow set PORTA.1 OFF
InitSer (1, r2400, 1+WaitForStart, 8, 1, none, normal)
main:
SerReceive (1, Temp)
EpWrite (1, Temp )
EpWrite (2, Temp )
EpWrite (3, Temp )
EpWrite (4, 0X40 ) 'as a reference if anything is written at all....
poke 6, 1
wait 50 10ms
poke 6, 0
goto main
if i send e.g. a blank i see the LED flashing.
after that i'd expected "20" at address 1, 2 and 3 in the eprom memory of the PIC. but when i read it out i have FF, FF, FF, 40
...sorry if this has been asked already... i spent a while trying to find a 'search' function for this forum but was not able to find anything.
thanks
daniel
i'm using an 4MHz quarz, btw.
you've got no direction on ports?
dir PORTB OUT
dir PORTC IN
From memory, the MAX232 inverts the signal. Try changing the last parameter of InitSer from normal to invert, and see if that helps.
There are also a couple of minor things in the program that you'll need to change:
- Remove the "set" from the constants for RecAHigh/Low. This is an easy mistake to make, I've done it several times included in a help file (now fixed).
- Add something to set the directions of the pins. These 2 lines should do this:
Dir PORTA.1 in
Dir PORTB out
Also, you can just use "PORTB = 1" or "PORTB = 0" in GCBASIC, no need for the poke unless that's what you prefer.