use The DSM module with clock as carrier source and switich it on/off with the MDBIT bit in the MDCON register under control of a counter
use The DSM module with clock as carrier source and switich it on/off with the MDBIT bit in the MDCON register under control of a counter
Warning I'm not a teacher
Yes, I need duty cycle of 50%, this is for HSS strobe application.
LATA makes no difference in speed, already tried.
can HPWM generate 4mhz signals? and counter, count them?
What is DSM module?
Like I said, LATA has nothing to do with the speed but will help you from getting into another read-modify-write problem. Feel free to ignore....
DSM is digital signal modulator, a peripheral available on the 16F1829, see section 23 in the datasheet.
According to the manual the maximum frequency for HPWM is 32768Hz but that doesn't stop you from configuring the CCP module manually. At 32MHz it should be capable of generating 4MHz (but not 4mHz). Check out the Reference Clock Module as well, might be better than the CCP module as Richard suggests.
/Henrik.
I had issue with read-modify-write on 628A. 1829 in same conditions works just fine.
RWM again lol.
Some ideas...
Slower, but at least it’s 50% duty cycle
can you afford to waste a whole port?Code:‘ Not RWM safe! flipflop var bit cycle: flipflop = flipflop + 1 portb.0 = flipflop goto cycle
faster than what you posted above.Code:‘ Is RWM safe! flipflop var byte flipflop = %01010101 cycle: portb = flipflop @comf _flipflop goto cycle
You need two consecutive nop instructions to balance the goto for %50 duty cycle in the loop you posted.
Thanks, but how control amount of cycles?
doing it that way won't get past a few hundred kilohertz‘ Is RWM safe!
flipflop var byte
flipflop = %01010101
cycle:
portb = flipflop
@comf _flipflop
goto cycle
its easy with the dsp module ,but the last pulse is difficult to control
if being 1 pulsE short sometimes this works great for a 4MHz output stream
Code:'**************************************************************** '* Name : MODULATOR.BAS * '* Author : richard * '* Notice : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 5/29/2016 * '* Version : 1.0 * '* Notes : 4MHZ CARRIER FOR X PULSES x=10 to 65535 * '* : 16F1825 * '**************************************************************** #CONFIG __config _CONFIG1, _FOSC_INTOSC & _CP_OFF & _WDTE_ON & _PWRTE_ON & _MCLRE_ON & _CLKOUTEN_OFF __config _CONFIG2, _PLLEN_ON & _LVP_OFF #ENDCONFIG OSCCON=$70 DEFINE OSC 32 @TIMER1=TMR1L ' PIC 16F1825 TRISA = %111111 ' Make all pins Input trisc = %101111 ;Make all pins Input ANSELA=0 ANSELC=0 CLKRCON= %11110011 MDCON= %11000000 MDSRC= %00000000 MDCARH =%00100011 MDCARL =%00000000 X VAR WORD TIMER1 VAR WORD EXT ' ;debug -------------------------- ' TRISA.0 = 0 ' lata.0=1 ' pause 2000 ;debug ' serout2 PORTa.0,84, ["ready v3",13,10 ] ;debug ' ;debug ------------------------------------ ; moddout is portc.4 X=40 Main_Loop: TIMER1=~(X-6) ASM BCF PIR1,0 MOVE?CT 1,MDCON,0 MOVE?CB 0X71,T1CON COFF BTFSS PIR1,0 ; BRA COFF MOVE?CT 0,MDCON,0 MOVE?CT 0,T1CON,0 ENDASM PAUSE 200 goto Main_Loop end
Warning I'm not a teacher
Bookmarks