PDA

View Full Version : Finally trying to do some serial- Won't compile :(



cncmachineguy
- 25th January 2011, 02:55
using 16F1947
PBP2.6A
MPLAB 8.53
and heres the big code:


INCLUDE "MODEDEFS.BAS"

DEFINE HSER2_RCSTA 90H
DEFINE HSER2_TXSTA 20H
DEFINE HSER2_BAUD 2400
DEFINE HSER2_CLROERR 1

LED0 = 0
START:
HSERIN2 [WAIT("S"),SPEED]
LED0 = 1
HSEROUT2 [SPEED]
'HESRIN2 [WAIT("G")]
GOTO START



Heres the errors:


ERROR: Macro HSERIN2WAIT?CL not found in macro file.
ERROR: Macro HSERIN2?B not found in macro file.
ERROR: Macro HSEROUT2?B not found in macro file.



edit: forgot to mention if I take out the "2's" as if using EUSART1, it will compile as is

mackrackit
- 25th January 2011, 03:31
There is nothing wrong with your code, it is something in PBP.
You code works with other two port chips.

Contact Melabs and ask for Darrel :)

mackrackit
- 25th January 2011, 03:33
BTW...

INCLUDE "MODEDEFS.BAS"
is not needed.

And your code only worked with the other chips when the VARs were defined. ;)

cncmachineguy
- 25th January 2011, 03:43
There is nothing wrong with your code, it is something in PBP.
You code works with other two port chips.

Contact Melabs and ask for Darrel

Leave it to me to find a problem. OK I will attempt to contact them/him


BTW...

INCLUDE "MODEDEFS.BAS"
is not needed.

I didn't think so, but I put it in when it didn't work. Seemed to be the "regular" answer. I will take it out.


And your code only worked with the other chips when the VARs were defined. ;)

Heres the full code:


' Name : Interface card.pbp
' Compiler : PICBASIC PRO Compiler 2.6A
' Assembler : MPASM
' Target PIC : 16F1947
' Hardware : PIMill Interface
' Oscillator : internal
' Keywords :
' Description : PICBASIC PRO program to interface parallel port
' to 4 stepper drives and limit switches
'
INCLUDE "MODEDEFS.BAS"
'
'
'
' Configure ports
'
'
ANSELA = %00000000 'port A all digital
ANSELE = %00000000 'port E all digital
ANSELF = %00000000 'port F all digital
ANSELG = %00000000 'port G all digital

CM1CON0 = %00000000 'No comparaters
CM1CON1 = %00000000
CM2CON0 = %00000000
CM2CON1 = %00000000

' preload latches before setting direction
LATB = %00000000
LATC = %00000000
LATD = %00010000 'LED's 0 for red, 1 FOR GREEN should start red
LATF = %00001111 ' low nibble is drive enable. 1 disables
LATG = %00000000

' I/O direction

TRISA = %11111111'step and dir inputs
TRISB = %11000001'7-0 icsp,icsp,h4o,h3o,h2o,h1o,estopO,enable In
TRISC = %00000000'step and dir outputs
TRISD = %01100000'led6,i2c,i2c,led5,led4,led3,led2,led1
TRISE = %11111111'ls4,lsh4.ls3,lsh3,ls2,lsh2,ls1,lsh1
TRISF = %10010000'manual ready,servo out,dac out,flood input,4en,3en,2en,1en
TRISG = %11100111'x,x,icsp/mclr,rly2,rly1,Rx2,Tx2,SPINDLE ON




'REMOVE THIS LINE IF NOT SETTING THE CONFIGS IN CODE SPACE
@ __config _CONFIG1,_FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
@ __config _CONFIG2,_WRT_OFF & _VCAPEN_OFF & _PLLEN_ON & _STVREN_OFF & _BORV_25 & _LVP_OFF

'Internal osc setup
OSCCON = %11110000 'clock is 8 meg. turn on PLL for 32 meg clock
DEFINE OSC 32
DEFINE NO_CLRWDT 1

'Variables
'Port assignments
'------------------port B
ENALL VAR PORTB.0
ESTOPO VAR PORTB.1
HO1 VAR PORTB.2
HO2 VAR PORTB.3
HO3 VAR PORTB.4
HO4 VAR PORTB.5
'------------------port D
LED0 VAR PORTD.0
LED1 VAR PORTD.1
LED2 VAR PORTD.2
LED3 VAR PORTD.3
LED4 VAR PORTD.4
LED5 VAR PORTD.7
'------------------port F
EN1 VAR PORTF.0
EN2 VAR PORTF.1
EN3 VAR PORTF.2
EN4 VAR PORTF.3
DIGIN VAR PORTF.5
SERVO VAR PORTF.6
MANREADY VAR PORTF.7
'------------------port G
SPINON VAR PORTG.0
RLY1 VAR PORTG.3
RLY2 VAR PORTG.4
'---------------------Bytes
CNT VAR BYTE
FRAMECT VAR BYTE
POS VAR BYTE
MYFLAGS VAR BYTE
PRELOAD VAR BYTE
SPEED VAR BYTE
DUMRUN VAR BYTE
'---------------------Bits
COUNTUP VAR MYFLAGS.0
COUNTDN VAR MYFLAGS.1
MS VAR MYFLAGS.2
LIMIT VAR MYFLAGS.3
DRIVEON VAR MYFLAGS.4
HOMED VAR MYFLAGS.5
READYSW VAR MYFLAGS.6
'---------------------INIT VARIABLE VALUE
READYSW = 0
HO1 = 1
HO2 = 1
HO3 = 1
HO4 = 1
COUNTUP = 1
COUNTDN = 0
POS = 127
FRAMECT = 0
MS = 0
HOMED = 0
CNT = 0
SPEED = 0
PRELOAD = 39 'PRELOAD 39 PR = NUMBER OF CYCLES-1

DEFINE HSER2_RCSTA 90H
DEFINE HSER2_TXSTA 20H
DEFINE HSER2_BAUD 2400
DEFINE HSER2_CLROERR 1

LED0 = 0
START:
HSERIN2 [SPEED]
LED0 = 1
HSEROUT2 [SPEED]
'HESRIN2 [WAIT("G")]
GOTO START


Just posting for the VAR's sake.

mister_e
- 25th January 2011, 04:08
From what I see in the .LIB file, it seems the 2nd USART is not implement yet in any 16F... PIC(tm)

cncmachineguy
- 25th January 2011, 04:31
Seems like I missed that declaration of limitation when deciding to buy.

mister_e
- 25th January 2011, 04:53
I, you or some, could copy paste HSERIN macros (and some other compiler directives), modify it, include them in the .LIB so you have a "fully workable" 2nd USART... but it belongs to Melabs to fix :p

Nothing stop you to implement a home-made one though...

Charles Linquis
- 25th January 2011, 05:53
Modifying .LIB files works well, but it is a mixed blessing when MELabs releases a new version. You want the new features, but you have to be really careful to move your changes into the new library. When that time comes, I highly recommend the program ARAXIS MERGE.

cncmachineguy
- 25th January 2011, 13:05
Thanks for the help guys. I looked at the LIB files and I don't want to mess with them. I will try my luck with support, until then I guess I will just do it "long hand". It seems to me the advantage of HSERIN/HSEROUT is easy array TX/RX and data formating.

Can anyone confirm this?

mister_e
- 25th January 2011, 14:36
true. do you need all features, high baudrate and interupts? In meantime can DEBUG/SERIN be enough?

cncmachineguy
- 25th January 2011, 14:46
I am not sure what "all features" are. No I don't need high Baud or interupts. I DO need to use the 2nd UART and not the 1st. I am trying to play with SERxxx2 now just to establish board function and communcation with PC. When I have that working, I will move on to the hardware UART. I am hoping by then maybe Melabs will have an answer as to fixing the omission or not. From there I will decide how I want to code the hardware UART based on their answer. Right now I am feeling like a "PBP talking to the registers" is going to be the answer. Thats still a tiny bit simpler then writing it in ASM.

Or I will come up with an "include" file so I can use it like HSERxxx. maybe I'll call it BSHIN and BSHOUT!

ScaleRobotics
- 25th January 2011, 15:07
Sounds like The hardware serial port 2 should be on this bugs list, as well as HPWM for the chips that have multiple HPWM but can't use the command. At least with HPWM you can easily control it manually though.

http://melabs.com/support/pbpissues.htm

cncmachineguy
- 25th January 2011, 22:51
Well I heard back from Melab. They confirmed the 2nd Usart has been overlooked in the 16F devices. They said there may still be time to include it in the 2.6B patch. But not sure just yet. So for me, I guess only time will tell if they fix it before I need it. And with the way I work, it may take me a month to need it, or could be tomorrow - LOL

mister_e
- 25th January 2011, 22:59
That's what happen when the PCB is design first :D

Wish you a month before needing it ;)

ScaleRobotics
- 26th January 2011, 00:14
Well I heard back from Melab. They confirmed the 2nd Usart has been overlooked in the 16F devices.

Or, to throw a really big wrench in, sounds like you could change to a PIC18F6722 or similar PIC18 device, and have two serial ports.

cncmachineguy
- 26th January 2011, 01:50
@ steve, somewhere I missed the part about designing hardware around the UNKNOWN compiler limitations instead of the hardware requirements.

@walter, I will look at those chips and see if I want to change.

Now don't get me wrong, this is no show stopper by any means. Simply a matter of (in)convience:D

mister_e
- 26th January 2011, 16:25
It's a hidden free feature not much ;)

I feel your pain, I think we all hit one of those feature once in a while. At least Melabs are aware and they have it listed, so it's all good. Just need to wait a lil bit.

Fortunately, in your case, "this is no show stopper by any means".