Data Signal Modulator (DSM) for some special PICs

Started by Yasin, Apr 03, 2021, 10:25 PM

Previous topic - Next topic


Maybe someone wants to generate serial data directly from the pin of the processor. Maybe it can be added to the compiler as "FSKOut".  :)



For such a specialist mechanism, a library will need to be created.

Now that the compiler has procedures, new commands are not required.

Stephen Moss

Quote from: Yasin on Apr 03, 2021, 10:25 PMMaybe someone wants to generate serial data directly from the pin of the processor.
A few years back I wrote a routine to produce and FSK type output when trying to help a student, this may not do exactly what you want but it may get you started
' Simulate with PIC18_ALCD

;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Device = 18F452

Declare Reminders Off
@ CONFIG_REQ = 0 ; Override Compiler's configuration settings
__Config Config1H, 0x22 ;OSC_HS & OSCS_OFF
__Config Config2L, 0x0D ;PWRT_OFF & BOR_OFF & BORV_20
__Config Config2H, 0x0E ;WDT_OFF & WDTPS_128
__Config Config3H, 0x01 ;CCP2MUX_ON
__Config Config4L, 0x85 ;STVR_ON & LVP_ON & DEBUG_OFF
__Config Config5L, 0x0F ;CP0_OFF & CP1_OFF & CP2_OFF & CP3_OFF
__Config Config5H, 0xC0 ;CPB_OFF & CPD_OFF
__Config Config6L, 0x0F ;WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF
__Config Config6H, 0xE0 ;WRTC_OFF & WRTB_OFF & WRTD_OFF
__Config Config7L, 0x0F ;EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF
__Config Config7H, 0x40 ;EBTRB_OFF
Declare Reminders On

;**** End of Fuse Configurator Settings ****
Xtal = 20

'Set Tris Registers
TRISA = $00
TRISB = $00
TRISC = $00
TRISD = $00
TRISE = $00

'Set port pin default output states
PORTA = $00
PORTB = $00
PORTC = $00
PORTD = $00
PORTE = $00

'Setp LCD Display
LCD_Type = Alpha
LCD_Interface = 4

'Setup Variable & Constants
Dim Half_Period As Word 'Variable holding half period of FSK frequency
Dim Cycles As Byte      'Variable holding number of cycle displayed
Dim MaxCycles As Byte  'Variable holding Maximum Nuber of Sycles to be displayed
Dim Mask As Word        'Variable holding Mask for checking Test data
Dim A As Byte          'Variable for holding result of Test data logically ANDed with the Mask

Symbol Info = %11001010 'Constant holding dummy test data

Start:                  'Start of Main program
Mask = $0001            'Initial Mask Value

While Mask < $0100      'Test all 8 bits of data
A = Info & Mask        'Mask of data bit to be tested
If A = 0 Then
Half_Period = 250 : MaxCycles = 10  'Set Frequency, 250 = 2KHz (values in uS). MaxCycles set to keep bit length equal.
Half_Period = 500 : MaxCycles = 5    'Set Frequency, 500 = 1 KHz(values in uS). MaxCycles Set To keep Bit length equal.

GoSub FSK              'Jump to the bit that does the work
Mask = Mask * 2        'Alter Mask to test the next bit of data

DelayUS 10000          'Wait 10mS - to seperate data bytes
GoTo Start              'Repeat endlessly

'Output signal on PortC.1 (5 cycles per bit)
For Cycles = 1 To MaxCycles
High PORTC.1
DelayUS Half_Period
DelayUS Half_Period
Next Cycles

GoTo Start              'Back stop just in case return form subroutine fails
End                    'Back stop if it all goes really pear shaped