PDA

View Full Version : Navtex Receiver



santamaria
- 21st March 2008, 14:18
I start to built a navtex receiver with 16f876.i found on net sample code but it is in assembly and i can't understand what happends there.With little asm code that i can undestand i found that working with capture module to find if the sitor bits is 1 or 0 ,also he enables timer0 for taking 10 samples per sitor bits pwm etc.I can't understand how the interrupt is working and how to decode the navtex signal.I don't care about serial input or output or how to drive the lcd(i have made working code for lcd).below i have the code and if someone can explain me what he is doing there to start built the code or if it is possible to add the assembly code for reception and then put my code there but i don't know how to work with variables in assembly and pbp.

thanks

skimask
- 21st March 2008, 15:36
That's only 40+ pages of assembly code...bit-banged serial routines, bit-banged LCD routines, and so on and so on...
I think it's time to put it in the round file and start from scratch...

santamaria
- 22nd March 2008, 09:04
thanks skimast for your reply. I know how many pages are and thats why i am comfused with the program(think also that i don't know assembly).don't give me code only the steps to start building it. take out lcd and serial commands. I can't understand also when the timer0 start.after capture interrupt? and also the receiver character is not ASCII he convert it but can't translate how.

santamaria
- 22nd March 2008, 13:00
when i compile the code with mplab and download it to the chip the chip doen't start. i measure with osciloscope the crystal and seems doesn't start.i face again this kind of problem and it was define different crystal value than i had in breadboard(in PBP).i am using 8 MHz crystal which working (i test it )and also i put in program that local is 8Mhz.i don't know how i can define in assembly that i am working with 8MHz crystal?

thanks

JD123
- 22nd March 2008, 14:06
Set config to HS oscilator type. Aslo, using an o-scope probe on a crytal may load the crystal to the point where it quits. Use a spare port and slap it around to see if the PIC is running.

santamaria
- 23rd March 2008, 19:51
I did it but the programm is not running .I will also check with XT configuration.Is it possible to define the crystal frequency in assembly as we do in PBP.?

mister_e
- 23rd March 2008, 21:04
It's already done in your code...

__CONFIG _CP_OFF& _WDT_OFF & _PWRTE_ON & _HS_OSC & _LVP_OFF & _BODEN_ON

syntax is syntax, seems to miss a space between _CP_OFF and the &... if you have any compilation error, it might just forget the config fuses?

Which device programmer do you have?

With the same config line, did you tried a simple Led Blink program?

Is there any chance to have
the schematic of it?
A picture of your current Prototype?

If you're using an o-scope to monitor your crystal... make sure you set your probe to 10X or 100X, unless you'll just screw the poor osc signal.

santamaria
- 23rd March 2008, 21:40
mister e i will explain you what i am doing. i download the above code from net and i compiled with mplab(succesfull). i burn the 16f876 and the chip doesn't start.in the same breadboard i made a sample program to test the lcd screen in pbp.it works like a charm.everything is the same exept the programm. If i understand correct my problem is with crystal config.the sample programm that i made has the same configuration bits and works(i didn't write the line a made it manualy from programmer).i am thinking to check now with XT config to see what happends. I use usb programmer from melabs and also i found from my friend the picstart plus and i tried it with mplab with no success.i put the navtex code in microcode studio but i had a lot of errors and i leave it .the diagramm is below if can be help you.i did't made it all ,only the digital circuit i build (pic ,lcd,max232,buttons), the receiver i don't want it now i want to check the decoder first and the lcd screen.Also i am not checking only the crystal with scope , by the programm must give my 500KHz in 12 pin.What else can i do?

santamaria
- 24th March 2008, 10:28
finally it works.... i would like to ask how i can pass this code to microcode studio and execute the labels that i want(and interrupts)?

santamaria
- 1st April 2008, 19:05
below is my sample fsk decoder similar to above code.i would like to ask how can i check if it is in phase or not and how i can read the bits that receiving in main programm? i upload also the specific assembly code for checking the phase.

thanks

mister_e
- 1st April 2008, 19:16
in your asm code... ; if sample = inphase then donothing

think about it a little bit ;)

santamaria
- 1st April 2008, 20:12
I stack now. I know that one sitor bit is 10msec. so i use tmr0 to find if it is in phase with samples, but how i know if i am in the start of sitor bit or in 3 msec after? I say that 10 samples is 1 sitor bit ok but i don't know if i start from the begining.Can you explain it to me mister_e?

mister_e
- 1st April 2008, 20:41
Here's a tips on how to mix ASM and PBP.


' Using PIC16F88
@ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF

DEFINE OSC 4
OSCCON=%01101000
ANSEL=%00000000
CMCON=%00000111

trisa = %11111111
trisb = %00000001

DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 25 ' 9600 Baud @ 4MHz, 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically

CounterA var byte BANK0
CLEAR

Start:
asm
CHK?RP PORTB
BTFSC PORTB,0
GOTO $-1
INCF _CounterA,F
ENDASM
HSEROUT ["CounterA=",DEC CounterA,13,10]
PAUSE 200
GOTO START

You define your variable in PBP, then you access them in ASM. Possible to use the other way... BUT not 100% sure if this is safe though... sure it isn't 'cause you can't know for sure where PBP will place it's own variables.

santamaria
- 1st April 2008, 21:23
Thanks for your reply mister_e. Tomorrow i will try in PBP and i will tell you my results.

santamaria
- 13th April 2008, 15:29
i am using darrel's interrupts and 20MHz crystal. With mister_e calculator i found that i want prescaler 1:32 and preload 99 into tmr0.I don't know how to preload the value into timer.below i have the interrupt routine of my program. Is this correct for preload the value?


'---[TMR0 - interrupt handler]--------------------------------------------------
Tick0: ;every 1ms occurs

;make space for new sample
cp_old=cp_new ;save old value
cp_new.highbyte=CCPR1H ;take new capture
cp_new.lowbyte=CCPR1L
gosub samplebit ;take the sample bit

TMR0=99

@ INT_RETURN

thanks

mister_e
- 13th April 2008, 19:31
if you're still using the 16F876 and want to have an interrupt each ~1mSec.. then yes.

Easy huh?

santamaria
- 13th April 2008, 21:09
Thanks mister_e.it was very easy to be true. I would like to ask you what is in your timer calc the re-load variable because i can't understand it.

thanks again for you reply.

regards

mister_e
- 13th April 2008, 21:45
If you know how much clock instruction cycle it takes to reload your timer, you set Reload (instr. cycle) (some call it fudge factor) with this value to fine tune your Preload results.

If you don't know AND/OR don't need 100% accuracy, just forgive it ;)

I understand how and why i'd place it there... but the language barrier stop me today... Darrel, Bruce, someone?