First before I start, GCB (Graphical with a bit of text editing), what a great way to get into PIC microcontroller programming….Stunning! I'm at a total loss why it isn't more popular….
After a hell of a lot of buggerising (to use a Australian term) around I have RS232 serial Comms going quite nicely on to Hyperterminal using the HSerPrint Command, Wonderful readable ASCII text and the like, as well as Variables printing out quite nicely using HSerSend!
I have a few questions:
…Oh and yes I did search through the forums before hand…
1)
How do I send a Raw Hex Byte in RS232? I want to enter a carriage return (to change line) and a New line command to HyperTerminal? Eg 0D (Carriage Return) and 0A (New Line) I tied HSerSend and HSerPrint but it outputs 0D and 0A as ASCII…
2)
For my project, I'm playing with a solid state MEMS Gyro package, which communicates via SPI. I haven't got to the stage of trying to talk to the pack yet, but I'm wondering if I can use the SPI bus on the PIC's USART at the same time (well read from one and transmit out the other) as using RS232?
3)
The Gyro Data needs to come out on the RS232 line as a 2 Byte hex value. Eg .274G would be written in HexaDecimal form as 0A0B (2740 in Decimal, then Divided by 100) It there a way in GCB to get rid of the Decimal conversion in the HSerSend command by editing one of the compiler libarys?
4)
While I can (and Have!) compiled and run my Programs through the compile button in Visual GCB, I actually want to do a little Hand editing of the Assembly file before doing the final compile.
If I click on view assembly code, I can generate a ASM file. Cool. Now how do I compile this? I tried various compilers, and no joy. I tried to get the GCB compiler to work, but no joy…Has anybody got any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Question (1) : look in your gcbasic/include/lowlevel/usart.h for examples of using hser
'Send CR and LF
'
Sub HserPrintCRLF
HserSend(13)
HserSend(11)
End Sub
I am not sure of how your used HserSend? Did you use hex $0A?
Question (2)
I would be nice to know which processor you are using.
The MSSP SPI is separate from the usart. I have never implemented the hardware spi but have a project that needs it too.
Qusetion (3)
Again look in the gcbasic/include/lowlevel/lcd.h for an example of breaking up a word variable into decimal. Specifically look at sub LCDWord(In LCDValue as word) . i am not saying to use an lcd, iam saying that this shows how to break it up into decimals.
GL
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1)
Well I've been using the serial comms commands like this:
HSerPrint "Test"
(Prints Test, via the USART through to Hyperterminal)
HSerSend Var
(prints a variable, eg if Var = 2300 then I'll get 2300 out on Hyperterminal)
So If I follow your logic HerSend (13) is sending a Hex D which is a CR….And for example my Termination Signal to the master processor is 7F then FF, which would be:
HserSend(127)
HserSend(255)
Cool! That makes Sense! :D To be honest why didn't I use HserPrintCRLF?!?! Ah well….I'll fire up my software and see how I go!
2)
I'm using a PIC16F873A, which has a hardware USART. Seems to be quite happy as it is. The RX and the TX pins are seperate from the SPI pins. The only wierd thing I have had to do with this PIC is swap the High and low signal pins around, eg
#define SendAHigh SET PORTC.6 OFF
#define SendALow SET PORTC.6 ON
Once I have my Comms up and running I'm going to throw myself headfirst into the SPI part of the project….I'll just use of of the otherouputs as a Slave select line.
3) Cool I'll look into it.
I probably could have got around it by myself if I could get a GCB generated ASM file to compile manually, It hits a lot of errors and I tried to move libary files around and the like….no such luck tho!
Cheers for your help anyway! :D
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
4) Haven't used GCGB personally. But looking at the GCGB folder, it's a lot more tightly integrated than the standard text based GCB. A few thoughts:
a) In the past, I've imported the compiled.asm file into a MPLAB, or AVR Studio, project, and messed around with the assembler there. You should be able to do the same with the GCGB.asm file.
b) Try to just add the assembler in the command box, it looks good to me.
c) If you specify what exactly you are trying to do with the additional assembler, than maybe someone could provide some additional help or tips.
d) Took a half swing at using the GCB BAT files to spit out a hex file from the gcgb.asm file, but no luck.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
;Defines (Constants)
#define SendAHigh SET PORTC.6 OFF
#define SendALow SET PORTC.6 ON
#define RecAHigh SET PORTC.7 ON
#define RecALow SET PORTC.7 OFF
#define USART_BAUD_RATE 9600
;Variables
Dim Var As word
Dim GyroTemp As word
'Setup rs232 Port
InitSer 1, r9600, 1, 8, 1, None, Invert
Dir PORTA.0 Out
Dir PORTC.6 Out
Dir PORTC.7 In
Here is my working RS232 startup…..except I cant remember where I had the invert set….I was going to quickly confirm the code was still working, but alas it seems my poor pic has died, I'll have to shoot into town to grab another one.
The inital problem was my waveform was upside down and back to front….
.
..
…
I did the coding changes, but alas untill tomorrow I cannot test it…grumble!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First before I start, GCB (Graphical with a bit of text editing), what a great way to get into PIC microcontroller programming….Stunning! I'm at a total loss why it isn't more popular….
After a hell of a lot of buggerising (to use a Australian term) around I have RS232 serial Comms going quite nicely on to Hyperterminal using the HSerPrint Command, Wonderful readable ASCII text and the like, as well as Variables printing out quite nicely using HSerSend!
I have a few questions:
…Oh and yes I did search through the forums before hand…
1)
How do I send a Raw Hex Byte in RS232? I want to enter a carriage return (to change line) and a New line command to HyperTerminal? Eg 0D (Carriage Return) and 0A (New Line) I tied HSerSend and HSerPrint but it outputs 0D and 0A as ASCII…
2)
For my project, I'm playing with a solid state MEMS Gyro package, which communicates via SPI. I haven't got to the stage of trying to talk to the pack yet, but I'm wondering if I can use the SPI bus on the PIC's USART at the same time (well read from one and transmit out the other) as using RS232?
3)
The Gyro Data needs to come out on the RS232 line as a 2 Byte hex value. Eg .274G would be written in HexaDecimal form as 0A0B (2740 in Decimal, then Divided by 100) It there a way in GCB to get rid of the Decimal conversion in the HSerSend command by editing one of the compiler libarys?
4)
While I can (and Have!) compiled and run my Programs through the compile button in Visual GCB, I actually want to do a little Hand editing of the Assembly file before doing the final compile.
If I click on view assembly code, I can generate a ASM file. Cool. Now how do I compile this? I tried various compilers, and no joy. I tried to get the GCB compiler to work, but no joy…Has anybody got any ideas?
Question (1) : look in your gcbasic/include/lowlevel/usart.h for examples of using hser
I am not sure of how your used HserSend? Did you use hex $0A?
Question (2)
I would be nice to know which processor you are using.
The MSSP SPI is separate from the usart. I have never implemented the hardware spi but have a project that needs it too.
Qusetion (3)
Again look in the gcbasic/include/lowlevel/lcd.h for an example of breaking up a word variable into decimal. Specifically look at sub LCDWord(In LCDValue as word) . i am not saying to use an lcd, iam saying that this shows how to break it up into decimals.
GL
Mike
G'Day Mike
1)
Well I've been using the serial comms commands like this:
HSerPrint "Test"
(Prints Test, via the USART through to Hyperterminal)
HSerSend Var
(prints a variable, eg if Var = 2300 then I'll get 2300 out on Hyperterminal)
So If I follow your logic HerSend (13) is sending a Hex D which is a CR….And for example my Termination Signal to the master processor is 7F then FF, which would be:
HserSend(127)
HserSend(255)
Cool! That makes Sense! :D To be honest why didn't I use HserPrintCRLF?!?! Ah well….I'll fire up my software and see how I go!
2)
I'm using a PIC16F873A, which has a hardware USART. Seems to be quite happy as it is. The RX and the TX pins are seperate from the SPI pins. The only wierd thing I have had to do with this PIC is swap the High and low signal pins around, eg
#define SendAHigh SET PORTC.6 OFF
#define SendALow SET PORTC.6 ON
Once I have my Comms up and running I'm going to throw myself headfirst into the SPI part of the project….I'll just use of of the otherouputs as a Slave select line.
3) Cool I'll look into it.
I probably could have got around it by myself if I could get a GCB generated ASM file to compile manually, It hits a lot of errors and I tried to move libary files around and the like….no such luck tho!
Cheers for your help anyway! :D
Your answer to number (2) worries me.
You should be using:
#define baudrate 9600
InitUSART
and maybe
#define USART_BLOCKING
for setting up a hardware usart
You should not need :
#define SendAHigh SET PORTC.6 OFF
#define SendALow SET PORTC.6 ON
which are used to set up a software serial port.
GL
Mike
@jonogeo
4) Haven't used GCGB personally. But looking at the GCGB folder, it's a lot more tightly integrated than the standard text based GCB. A few thoughts:
a) In the past, I've imported the compiled.asm file into a MPLAB, or AVR Studio, project, and messed around with the assembler there. You should be able to do the same with the GCGB.asm file.
b) Try to just add the assembler in the command box, it looks good to me.
c) If you specify what exactly you are trying to do with the additional assembler, than maybe someone could provide some additional help or tips.
d) Took a half swing at using the GCB BAT files to spit out a hex file from the gcgb.asm file, but no luck.
Cheers Kent :)
I'll have a crack at the MPLAB option….
@Mike
;Defines (Constants)
#define SendAHigh SET PORTC.6 OFF
#define SendALow SET PORTC.6 ON
#define RecAHigh SET PORTC.7 ON
#define RecALow SET PORTC.7 OFF
#define USART_BAUD_RATE 9600
;Variables
Dim Var As word
Dim GyroTemp As word
'Setup rs232 Port
InitSer 1, r9600, 1, 8, 1, None, Invert
Dir PORTA.0 Out
Dir PORTC.6 Out
Dir PORTC.7 In
Here is my working RS232 startup…..except I cant remember where I had the invert set….I was going to quickly confirm the code was still working, but alas it seems my poor pic has died, I'll have to shoot into town to grab another one.
The inital problem was my waveform was upside down and back to front….
.
..
…
I did the coding changes, but alas untill tomorrow I cannot test it…grumble!
jonogeo,
Looks like you are mixing both software and hardware commands.
Look in the contributors section of the forum for a usart example.
usart is the hardware serial which goes with HSerSend and HSerPrint commands.
gl
mike
Hrm it seems my programmer has a issue, writes to 18 Pin PIC's but not 28 Pin ones…..*sigh*
O.K I'm back on the air! New programmer (EasyPIC v6)
The HserPrintCRLF doesn't seem to work which is a bit of a bummer….I've just got back into it…..I'll put up a bit more progress in the next few days….
Just a quick question, where can I download the "lean" USART driver libary?